的Android getContentResolver()的WHERE子句大量項目的WHERE子句中使用「IN」的Android getContentResolver()使用「IN」與大量的項目
我已經完全和它實現了這個查詢成功給需要的數據
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String projection[] = {MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.COMPOSER,
MediaStore.Audio.Media.DURATION,
// android.provider.MediaStore.Audio.Albums.ALBUM_ART,
MediaStore.Audio.Media.ALBUM_ID,
MediaStore.Audio.Media._ID,};
String selection1 = MediaStore.Audio.Media.IS_MUSIC + " = 1" + " AND "
+ MediaStore.Audio.Media._ID + " IN(";
for (int i = 0; i < SongsList.size(); i++) {// songslist is an array of IDs
selection1 += "?, ";
}
selection1 = selection1.substring(0, selection1.length() - 2) + ")";
String[] selectionArgs = new String[SongsList.size()];
selectionArgs = SongsList.toArray(selectionArgs);
Cursor cursor = this.getContentResolver().query(uri, projection, selection1,
selectionArgs, null);
然而,當項目的數量很大查詢失敗,
是否有一個WHERE子句中檢索與getContentResolver()的項目數量龐大,而無需使用「IN」的替代
爲什麼不使用'AsyncTask'以執行工作線程查詢? –
你可以提供一個例子與asynctask – 1234567