0
我有這個功能從developer.android但它找不到所有的歌曲,只有少數。請給我一些線索。MediaStore - 功能無法找到所有歌曲
public void getAllSongs() {
ContentResolver contentResolver = getContentResolver();
Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = contentResolver.query(uri, null, null, null, null);
if (cursor == null) {
// query failed, handle error.
} else if (!cursor.moveToFirst()) {
// no media on the device
} else {
int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media._ID);
do {
long thisId = cursor.getLong(idColumn);
String thisTitle = cursor.getString(titleColumn);
songs.add(thisId + "||"+thisTitle);// ...process entry...
} while (cursor.moveToNext());
}
}
在我的一個老問題,看一看,可能會幫助你http://stackoverflow.com/questions/32703442/populate- listview-with-mp3-files-found-locally – Phil3992
這是找到歌曲的好方法,但比我想要的要慢。但是,謝謝你的回答 – ufo13131
你並沒有要求查詢中的任何列。見下面 – Theo