我在从 Android 的播放列表中检索歌曲时遇到问题。我目前正在尝试使用以下代码来实现这一点(基于对此处给出的这个问题的回答):
String where = MediaStore.Audio.Playlists._ID
+ "=?";
String whereVal[] = {id};
String[] proj =
{
MediaStore.Audio.Playlists.Members.AUDIO_ID,
MediaStore.Audio.Playlists.Members.ARTIST,
MediaStore.Audio.Playlists.Members.TITLE,
MediaStore.Audio.Playlists.Members._ID
};
Cursor mCursor = getActivity().getContentResolver().query(
MediaStore.Audio.Playlists.Members.getContentUri("external", Long.parseLong(id)),
proj, where, whereVal, null);
其中 id 是我使用检索的播放列表 ID cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists._ID));
(我知道这是正确的)
但是,这会导致以下错误:
07-06 19:35:02.496: E/AndroidRuntime(8818): android.database.sqlite.SQLiteException:
ambiguous column name: _id (code 1): , while compiling: SELECT audio_id, artist, title,
audio_playlists_map._id AS _id FROM audio_playlists_map, audio WHERE (audio._id =
audio_id AND playlist_id=?) AND (_id=?)
我有一种有趣的感觉,问题出在以下几点:
String where = MediaStore.Audio.Playlists._ID + "=?";
但我不知道如何纠正它。