Code and comments are as follows:
Private Cursor GetCursor (string filePath) {string path = null;
Cursor C = getcontentresolver (). query (MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, NULL, NULL, NULL,
MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
System.out.println (c.getstring) (C.getcolumnindex ("_data")); if (C.movetofirst ()) {do {//Gets the path through cursor, if the path is the same; System.out.printl
N ("////////" +filepath);
Path = C.getstring (c. Getcolumnindexorthrow (MediaStore.Audio.Media.DATA)); System.out.println ("?????????"
+path);
Finding the same path returns, at which point Cursorposition is pointing to the cursor that the path can return to if (Path.equals (FilePath)) {
System.out.println ("audiopath =" + path);
System.out.println ("FilePath =" + FilePath);
Cursorposition = C.getposition (); Break
} while (C.movetonext ()); //These two have no effect, when debugging using//String audiopath = c.getstring (c//. Getcolumnindexorthrow (Mediasto Re.
Audio.Media.DATA));
System.out.println ("audiopath =" + audiopath);
return C; private string Getalbumart (int album_id) {string murialbums = ' content://media/external/a
Udio/albums ";
string[] projection = new string[] {"Album_art"}; Cursor cur = this.getcontentresolver (). Query (Uri.parse (murialbums + "/" + integer.tostring (album_id
), projection, NULL, NULL, NULL);
String album_art = null;
if (Cur.getcount () > 0 && cur.getcolumncount () > 0) {cur.movetonext ();
Album_art = cur.getstring (0);
} cur.close ();
cur = null; return album_art;
private void GetImage () {Cursor currentcursor = getcursor ("/mnt/sdcard/" +mp3info); int album_id = Currentcursor.getint (currentcursor. Getcolumnindexorthrow (MediaStore.Audio.Media.ALBU
m_id));
String Albumart = Getalbumart (album_id);
Bitmap BM = NULL;
if (Albumart = = null) {Mimageview.setbackgroundresource (r.drawable.staring);
else {BM = Bitmapfactory.decodefile (Albumart);
Bitmapdrawable Bmpdraw = new bitmapdrawable (BM);
Mimageview.setimagedrawable (Bmpdraw); }
}