Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:51:16+00:00 2026-06-11T05:51:16+00:00

I have a path like this: content://media/external/audio/media/7181 That was obtained like this String mSelectedPath

  • 0

I have a path like this:

content://media/external/audio/media/7181

That was obtained like this String mSelectedPath = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "/";
and then I append the song id to this.

I want to convert it into a path such as /mnt/sdcard/..

How do I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:51:18+00:00Added an answer on June 11, 2026 at 5:51 am

    Android’s media database stores the path to files in the DATA column. You can read that via

    long id = 7181;
    Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);
    
    ContentResolver cr = getContentResolver();
    String[] projection = { MediaColumns.DATA };
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = null;
    Cursor c = cr.query(uri, projection, selection, selectionArgs, sortOrder);
    String path = null;
    if (c != null) {
        if (c.moveToFirst()) {
            path = c.getString(0);
        }
        c.close();
    }
    Log.d("XYZ", "Path of " + id + " is:" + path);
    

    But like @CommonsWare said it’s possible that (especially on future android versions) there is no file you can access or even no path at all, meaning the path you get might be worthless.

    Luckily ContentProvider allows you to read data with IO streams if the provider has that feature implemented (IIRC this one does). So you could read the data represented by that Uri like in below example.

    long id = 7181;
    Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);
    
    ContentResolver cr = getContentResolver();
    InputStream is = null;
    try {
        is = cr.openInputStream(uri);
        is.read(); // replace with useful code.
    } catch (FileNotFoundException e) {
        Log.w("XYZ", e);
    } catch (IOException e) {
        Log.w("XYZ", e);
    } finally {
        if (is != null)
            try {
                is.close();
            } catch (IOException e) {
                // ignored
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have stored the XML path to items in a string like this: response->items->item
I have a url like this https://example.com%3A443:443/www/36d8e8c94aae45048ba9f92f8e62c7b2/file/content?path=%2Fmnt%2Fsdcard%2Fvideo%2Fsample_mpeg4.mp4&yyy=9a7491a1f5664336b5c6bf431f42852c3749ed54722736ec748746858a710c44 I need to get the path of
I have a piece of content that is structured like this: Body Common Containable
I have a path like this: parent/child/reply How do I use PHP to remove
I have an array of file path components like this: [ ['some', 'dir', 'file.txt'],
I have a path like C:\application\photo\gallery\sketches . Now I need to check whether this
I have a class this is annotated with @Path like so: @Path(widgets) @Produces(MediaType.APPLICATION_XML) public
I have xml like this: <configurationData> <path name='b'> <path name='a'> <setting name='s1'> ![CDATA[XXXX]] </setting>
I have stored images from the net like this Documents/imagecache/domain1/original/path/inURI/foo.png Documents/imagecache/domain2/original/path/inURI/bar.png Documents/imagecache/... Documents/imagecache/... Now
let's say i have directory paths looking like this: this/is/the/basedir/path/a/include this/is/the/basedir/path/b/include this/is/the/basedir/path/a this/is/the/basedir/path/b In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.