Question

i have a doubt regarding content provider.. we know binder cant transfer large amount of data (~>3MB) but even content provider uses binder IPC right which may involve >3 MB transfer? or content provider directly read database within caller process memory space and doesn't involve IPC ?

Please correct my understanding.

Was it helpful?

Solution

At the lowest level, content providers use CursorWindows, which are based on shared memory (ashmem).

Looking at the AOSP source file frameworks/base/libs/androidfw/CursorWindow.cpp, the lowest level C++ code does not seem to impose any restrictions on the shared memory size, other than those inherited from the system-level ashmem and mmap services.

The next code layer, frameworks/base/core/jni/android_database_CursorWindow.cpp, doesn't seem to impose any limits to the cursor window size either.

The Java code, frameworks/base/core/java/android/database/CursorWindow.java, reads the buffer size from the Android frameworks internal configuration value config_cursorWindowSize, which at least in KitKat seems to be 2048 by default. Hence, in KitKat the maximum CursorWindow size is 2 Mb if you use the normal Java interfaces. However, if you use the androidfw/CursorWindow.h directly from C++, using the AOSP headers, then you can use larger CursorWindows. (Note that just using the NDK is not enough, since the CursorWindow is not part of the NDK API.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top