Skip to content

Instantly share code, notes, and snippets.

@vincent1086
Created November 5, 2016 17:24
Show Gist options
  • Save vincent1086/0198dde9dc4a5aa16eac1c1fabe6a3c8 to your computer and use it in GitHub Desktop.
Save vincent1086/0198dde9dc4a5aa16eac1c1fabe6a3c8 to your computer and use it in GitHub Desktop.
Setup CursorAdapter Size
// Reference : http://pqovopq.seesaa.net/article/387726362.html
static private void setCursorWindowSize(int size){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
try {
final Class cls = Class.forName("android.database.CursorWindow");
final Field fld = cls.getDeclaredField("sCursorWindowSize");
fld.setAccessible(true);
int before = fld.getInt(null); // default=2048*1024
fld.setInt(null, size * 1024); // extend to
int after = fld.getInt(null);
Log.d(TAG, "sCursorWindowSize:" + before + "/" + after);
} catch (Exception e) {
Log.e(TAG, e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment