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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:21:22+00:00 2026-06-02T03:21:22+00:00

I have two questions: When I call my saveas(ressound); (inspired by stealthcopter.com) on a

  • 0

I have two questions:

  1. When I call my saveas(ressound); (inspired by stealthcopter.com) on a android 4.0.3 device the ringtone is nicely activated as a ringtone, but on a 2.3.3 device the selected ringtone is silent. Where did I go wrong in my code?

  2. The second thing that I want to know is how to delete the file. More importantly, how to get it out of the media store, does this happen automatically if I remove it from the sd?


UPDATE:

Added code to delete the whole folder plus content, works good and clean! (see below)

Try to call this code when I push a button:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); 

But it will not clean out the mediastore, it works with a reboot.
I also tried the media scan within the dev tools, but that doesn’t work. They mention that some apps need to restart, but how to restart the service responsible for displaying the list of available ringtones without rebooting the whole device?


variables:

String soundname;
int ressound;
int savetype;
String path="/sdcard/mysounds/";

savetype = RingtoneManager.TYPE_RINGTONE;
ressound = R.raw.sound1;
soundname = "sound1";

saveas(ressound);

//save as
  public boolean saveas(int ressound){
     byte[] buffer=null;
     InputStream fIn = getBaseContext().getResources().openRawResource(ressound);
     int size=0;

     try {
      size = fIn.available();
      buffer = new byte[size];
      fIn.read(buffer);
      fIn.close();
     } catch (IOException e) {
      return false;
     }

     String filename= soundname +".mp3";

     boolean exists = (new File(path)).exists();
     if (!exists){new File(path).mkdirs();}

     FileOutputStream save;
     try {
      save = new FileOutputStream(path+filename);
      save.write(buffer);
      save.flush();
      save.close();
     } catch (FileNotFoundException e) {
      return false;
     } catch (IOException e) {
      return false;
     }    

     sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename)));

     File k = new File(path, filename);

     ContentValues values = new ContentValues();
     values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
     values.put(MediaStore.MediaColumns.TITLE, soundname);
     values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
     values.put(MediaStore.Audio.Media.ARTIST, "Elvis");
     values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
     values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
     values.put(MediaStore.Audio.Media.IS_ALARM, true);
     values.put(MediaStore.Audio.Media.IS_MUSIC, false);

     //Insert it into the database
     Uri newUri = this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);

     // set as ringtone
     RingtoneManager.setActualDefaultRingtoneUri(this, savetype, newUri);

     return true;
    }

delete();

public void delete() {
    File a = new File(path, "sound1.mp3");
    a.delete();
    File b = new File(path, "sound2.mp3");
    b.delete();
}

deleteFiles(String path);

public static void deleteFiles(String path) {
    File file = new File(path);

    if (file.exists()) {
        String deleteCmd = "rm -r " + path;
        Runtime runtime = Runtime.getRuntime();
        try {
            runtime.exec(deleteCmd);
        } catch (IOException e) { }
    }
}
  • 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-02T03:21:24+00:00Added an answer on June 2, 2026 at 3:21 am

    “android.permission.MODIFY_AUDIO_SETTINGS”
    I think this solves problem one, did not find any problems until now.

    deleteFiles(String path);
    is a partly solution to problem 2
    After reboot the item is gone.

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

Sidebar

Related Questions

I have two questions: I have an object, call it X. When I assign
I have two questions : What if I have a JNI call to a
I have two questions here. How can I show the header of the pop
I have two questions. How can I get the spinner in the figure below
I have two questions. Does it make sense when I have to choice of
I have two questions. Question1: How can we add a reference to a third-party
I have two questions. I know it is possible to declare class objects in
I have two questions. I want to send SMSes from a web-site in PHP
I have two questions in regards to the PyDev (Python editor for Eclipse) and
I have two questions: 1) I have a few global variables for my website

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.