如何在片段内使用光标?这是我要设置的游标片段,但它说 managedQuery 未定义:
片段1.java
private List<String> getMp3FilesFromSDCard() {
//here we get the list of songs stored on the SD card and we update our singleton class
List<String> result = new ArrayList<String>();
SingletonPlaylist playlist;
playlist = SingletonPlaylist.getInstance();
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Cursor cursor;
String[] projection =
{
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME
};
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
cursor = this.managedQuery(uri, projection, selection, null, null);
cursor.moveToFirst();
while (cursor.moveToNext())
{
result.add(cursor.getString(5));
playlist.addSong(new Song(cursor.getString(0),cursor.getString(1),cursor.getString(2),cursor.getString(3),cursor.getString(4),cursor.getString(5)));
}
return result;
}
我怎样才能解决这个问题?