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 5963823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:19:20+00:00 2026-05-22T19:19:20+00:00

In my program, I want to save a selected ringtone by it’s file path,

  • 0

In my program, I want to save a selected ringtone by it’s file path, and then set it as the current ringtone later.

I have got the ringtone uri from RingtonePreference, and get the file path of it from MediaStore database.

e.g.

Uri - content://media/internal/audio/media/29
Path - /system/media/audio/notifications/Ascend.mp3

Now, how to I get the ringtone Uri from the file path i saved ?

Since the ringtone already exist in MediaStore, I tried the following functions, but it’s not working.

uriRingtone = MediaStore.Audio.Media.getContentUriForPath(szRingtonePath);

The Uri is not the same as the one I got from RingtonePreference.

uriRingtone - content://media/internal/audio/media

How do I query the MediaStore to get the Uri I need?

p.s. the reason that I don’t store the ringtone Uri directly is that I found the Uri for the same ringtone might change sometimes in some device.

  • 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-05-22T19:19:22+00:00Added an answer on May 22, 2026 at 7:19 pm

    The way you can recover the ringtone URI stored in the RingtonePreference is (as far as I know) by knowing the title of the song. Then you can query it by using a cursor to obtain the ringtone _id stored and with it you can build an URI:

    String ringtoneTitle = "<The desired ringtone title>";
    Uri parcialUri = Uri.parse("content://media/external/audio/media"); // also can be "content://media/internal/audio/media", depends on your needs
    Uri finalSuccessfulUri;
    
    RingtoneManager rm = new RingtoneManager(getApplicationContext()); 
    Cursor cursor = rm.getCursor();
    cursor.moveToFirst();
    
    while(!cursor.isAfterLast()) {
        if(ringtoneTitle.compareToIgnoreCase(cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.TITLE))) == 0) {
        int ringtoneID = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
            finalSuccessfulUri = Uri.withAppendedPath(parcialUri, "" + ringtoneID );
            break;
        }
        cursor.moveToNext();
    }
    

    where finalSuccessful uri is the uri pointing to the ringtone in the RingtonePreference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to save data to a file in my elisp program. I have
I want to save my program's DataModel objects to a file, and be able
My IOS application program have tableview in navigation controller secondview. I want to save
I want to save the objects I generated in a program. After restart the
I have a program and want to debug it in gdb. Will I see
I have a small program I want to execute to test something #include <map>
I am adding contact functionality to my program, and I want to save the
I have tons of objects which I want to save for offline use. Currently
If i have a program which draws rectangles, circles and lines and i want
I want to save the swtich state and load it when the program restarted.

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.