Android examples for Database:Cursor Get
get Id List From Cursor
//package com.java2s; import android.database.Cursor; import android.provider.BaseColumns; import java.util.ArrayList; import java.util.List; public class Main { public static List<Long> getIdListFromCursor(Cursor cursor) { long id = -1; List<Long> idList = new ArrayList<>(); if (cursor != null && cursor.moveToPosition(-1)) { while (cursor.moveToNext()) { id = cursor.getLong(cursor .getColumnIndexOrThrow(BaseColumns._ID)); if (id >= 0) { idList.add(id);//from ww w .ja v a 2s.c om } } return idList; } return null; } }