简体   繁体   中英

How to get track Uri from ContentResolver query?

i am traversing in the phone's memory with the following code.

ContentResolver contentResolver = getContentResolver();
    String[] columns = {
            MediaColumns._ID,
            MediaColumns.TITLE,
        AudioColumns.DURATION,

    };
    final String where = MediaStore.Audio.Media.IS_MUSIC + "=1";

    Cursor cursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,columns, where, null, null);

    while(cursor.moveToNext()) {
        String urp = cursor.getString(cursor.getColumnIndex(MediaColumns._ID));
        String title = cursor.getString(cursor.getColumnIndex(MediaColumns.TITLE));
        Long duration = cursor.getLong(cursor.getColumnIndex(AudioColumns.DURATION));
    }

so now my question is, how to get the uri of the cursor items traveresed, like for first while run i have stored id,title,duration etc metadata and i would also like to store that tracks URI, also i would like to convert that URI from content// scheme to file scheme.

Any help will be greatful thankyou

String.valueOf(cur.getColumnIndex(android.provider.MediaStore.MediaColumns.DATA)));

http://android-er.blogspot.fr/2011/04/convert-uri-to-real-path-format.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM