aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/utils/CursorUtils.java
blob: 69ae83924c8427c3fa1aaec1a61a9c0f7564630e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package de.pixart.messenger.utils;

import android.database.AbstractWindowedCursor;
import android.database.Cursor;
import android.database.CursorWindow;
import android.database.sqlite.SQLiteCursor;

public class CursorUtils {

    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);
            }
        }
    }
}