Android Mediastore Get Cursor Position By Comparing With Title_key
I am using MediaStore's media content and have a SearchView to filter the content displayed in a listfragment. I keep a reference to the cursor(mainCursor) when the query string i
Solution 1:
If you are just interested in the position, why dont you put the audio_ids in an array
ArrayList<String> audio_ids = newArrayList<String>();
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()){
String audio_id = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID));
audio_ids.add(audio_id);
}
and then use
Stringaudio_id= cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID));
position = audio_ids.lastIndexOf(audio_id);
This example queries playlists. The above example would give you the last position if you had duplicates. (something you perhaps had not thought about?) I hope this gives you some ideas
Post a Comment for "Android Mediastore Get Cursor Position By Comparing With Title_key"