有没有办法使用 where 条件将 Mediastore 游标设置为 Rowset 中的特定行?
Is there a way to set Mediastore cursor to specific row in Rowset using where condition?
我想将光标设置到行集中的特定行而不过滤行集。有没有办法在行集中的 where 条件下移动光标?我目前的解决方案是
// search for a _ID
if (cur != null) { // my row set
int idColumn = cur.getColumnIndex(MediaStore.Images.Media._ID);
cur.moveToFirst();
do {
if (search_id == cur.getInt(idColumn))) // row found
return; // ok, cursor in right position
} while (cur.moveToNext());
cur.moveToFirst(); // id not found
}
提前致谢
除非你事先知道游标的位置,否则你可以使用 cur.moveToPosition(integer_posisition)
,其中 integer_position 顾名思义,行在 Cursor 中的位置光标,注意第一行是第 0 行而不是第 1 行。
当然,如果您正在搜索特定行,您通常会使用查询来使用 WHERE 子句仅检索该行。
我想将光标设置到行集中的特定行而不过滤行集。有没有办法在行集中的 where 条件下移动光标?我目前的解决方案是
// search for a _ID
if (cur != null) { // my row set
int idColumn = cur.getColumnIndex(MediaStore.Images.Media._ID);
cur.moveToFirst();
do {
if (search_id == cur.getInt(idColumn))) // row found
return; // ok, cursor in right position
} while (cur.moveToNext());
cur.moveToFirst(); // id not found
}
提前致谢
除非你事先知道游标的位置,否则你可以使用 cur.moveToPosition(integer_posisition)
,其中 integer_position 顾名思义,行在 Cursor 中的位置光标,注意第一行是第 0 行而不是第 1 行。
当然,如果您正在搜索特定行,您通常会使用查询来使用 WHERE 子句仅检索该行。