这个看似简单的问题让我感到困惑。我有以下代码:
Cursor c = getContentResolver().query(
MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
new String[] {MediaStore.Audio.Playlists._ID, MediaStore.Audio.Playlists.NAME},
null,
null,
MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
c.moveToFirst();
Log.d("TestTest", String.format("Count is %d", c.getCount()));
for (int i = 0; i < c.getCount(); i++) {
c.moveToPosition(i);
int id = c.getInt(c.getColumnIndex(MediaStore.Audio.Playlists._ID));
String s = c.getString(c.getColumnIndex(MediaStore.Audio.Playlists.NAME));
Log.d("TestTest", "HEY! " + s + " " + String.format("%d", id));
}
计数报告为 1,显然我唯一的播放列表名为“m3u 播放列表”。
这里发生了什么?我有几个播放列表,只想打印一个列表。
感谢所有答案!