use of android.database.AbstractWindowedCursor in project android_external_GmsApi by microg.
the class DataHolder method getCursorType.
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
static int getCursorType(Cursor cursor, int i) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return cursor.getType(i);
}
if (cursor instanceof AbstractWindowedCursor) {
CursorWindow cursorWindow = ((AbstractWindowedCursor) cursor).getWindow();
int pos = cursor.getPosition();
int type = -1;
if (cursorWindow.isNull(pos, i)) {
type = FIELD_TYPE_NULL;
} else if (cursorWindow.isLong(pos, i)) {
type = FIELD_TYPE_INTEGER;
} else if (cursorWindow.isFloat(pos, i)) {
type = FIELD_TYPE_FLOAT;
} else if (cursorWindow.isString(pos, i)) {
type = FIELD_TYPE_STRING;
} else if (cursorWindow.isBlob(pos, i)) {
type = FIELD_TYPE_BLOB;
}
return type;
}
throw new RuntimeException("Unsupported cursor on this platform!");
}
use of android.database.AbstractWindowedCursor in project Conversations by siacs.
the class CursorUtils method upgradeCursorWindowSize.
public static void upgradeCursorWindowSize(final Cursor cursor) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
if (cursor instanceof AbstractWindowedCursor) {
final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
windowedCursor.setWindow(new CursorWindow("4M", 4 * 1024 * 1024));
}
if (cursor instanceof SQLiteCursor) {
((SQLiteCursor) cursor).setFillWindowForwardOnly(true);
}
}
}
Aggregations