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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:09:50+00:00 2026-06-17T16:09:50+00:00

I add a ring tone from a raw file like this code below, and

  • 0

I add a ring tone from a raw file like this code below, and it works.
Once I added it, I can open Android System Ringtones list and it appears there, so I (or any other app) can use it.
The problem is that if I restart the phone then that entry from the list is gone.
So, is there a way to permanently add a ringtone?
Thanks

I use this code for adding:

private void AddRingTone() //I assume that sdcard directory exists and it is empty
{  //We first copy the raw resource to sdcard:
   String sPath = Environment.getExternalStorageDirectory() + "/AnyPath"; //AnyPath already exists.        
   File newSoundFile = new File(sPath, "MyRingtone");
   Uri mUri = Uri.parse("android.resource://" + getPackageName()+ "/" + R.raw.myringtone);
   AssetFileDescriptor soundFile;
   try 
   {  soundFile= getContentResolver().openAssetFileDescriptor(mUri, "r");
   }catch (FileNotFoundException e)
   {  soundFile=null;   
      MessageBox("Cannot open " + mUri.toString());
   }
   try
   {  byte[] readData = new byte[1024];
      FileInputStream fis = soundFile.createInputStream();
      FileOutputStream fos = new FileOutputStream(newSoundFile);
      int i = fis.read(readData);
      while (i != -1)
      { fos.write(readData, 0, i);
        i = fis.read(readData);
      }
      fos.close();
   }catch(IOException io)
   {  MessageBox("RingtoneManager:\n" + io.toString());  
   }


   //Now we add it to the system list:
   ContentValues values = new ContentValues();
   values.put(MediaStore.MediaColumns.DATA, newSoundFile.getAbsolutePath());
   values.put(MediaStore.MediaColumns.TITLE, "my ring tone");
   values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/oog");
   values.put(MediaStore.MediaColumns.SIZE, newSoundFile.length());
   values.put(MediaStore.Audio.Media.ARTIST, "me");
   values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
   values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
   values.put(MediaStore.Audio.Media.IS_ALARM, false);
   values.put(MediaStore.Audio.Media.IS_MUSIC, false);
   Uri uri = MediaStore.Audio.Media.getContentUriForPath(newSoundFile.getAbsolutePath());
   Uri newUri = getContentResolver().insert(uri, values);

}

  • 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-17T16:09:50+00:00Added an answer on June 17, 2026 at 4:09 pm

    The reason it disappears, is its not stored in the right place!

    The official spot where Android keeps tabs on the media files is located in /sdcard/media/audio/Ringtones or /sdcard/media/audio/notifications, whichever suits best!

    Android knows zero about a directory called AnyPath and the media scanner does not pick it up!

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

Sidebar

Related Questions

I would like to add a Print-Ticket command to the ring menu in my
add and GetContentPane are methods Does this code access a method in a method?
I wrote a piece of code to add a ringtone from a URL in
add space top of page when use this code : <?php get_header(); ?> but
I add my url xxx/getjson.php to a webhook and once a person signup, it
to add clarity to the below. I was considering using timers or storyboard.CurrentTimeInvalidated but
function Add(a, b) { } If we call a javascript function like - onclick=Add(1)
I add this problem for quite some time when using NetBeans. Recently I add
In my soundboard app I have created a context menu using this code. public
add({ title: args.node.id, iconCls: 'tabs', items: [{html: '<code class=prettyprint><?php\necho \'Hello World!\';</code>', width: '100%', hieght:

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.