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