How fast is the .moveToPosition (i) cursor?

cursor.moveToPosition(i);Will satisfying the call lead to permanent storage operation or just reading from the memory cache?

In Android, RecycleView Adapterthis is called quite often, I do not want to overload the system by accessing persistent storage. Is there any risk at all?

Cursor cursor = MainActivity.db.rawQuery("Select _id From UserSetting", null);Will the operation produce a cached result?

@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {

    cursor.moveToPosition(i);
    int i2 = cursor.getColumnIndexOrThrow("_id");
    final String _id = cursor.getString(i2);
    itemHolder.itemRecordName = _id;
    int i3 = cursor.getColumnIndexOrThrow("text");
    final String text = cursor.getString(i3);
    int i4 = cursor.getColumnIndexOrThrow("userSettingRecordName");
    final String userSettingRecordName = cursor.getString(i4);
+4
source share
1 answer

There is a memory window for the cursor. but in the case of long jumps, your code will trigger io operations. Look for CursorWindow Details

+1
source

Source: https://habr.com/ru/post/1653779/


All Articles