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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:26:29+00:00 2026-05-24T06:26:29+00:00

I wrote a piece of code to add a ringtone from a URL in

  • 0

I wrote a piece of code to add a ringtone from a URL in Android 2.1. In Froyo it does not want to work at all.

sendBroadcast(new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri
.fromFile(file)));

ContentValues values = new ContentValues();

values.put(MediaStore.MediaColumns.DATA,
file.getAbsolutePath());

values.put(MediaStore.MediaColumns.TITLE, filenameBase);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");         
values.put(AudioColumns.IS_RINGTONE, true);
values.put(AudioColumns.IS_NOTIFICATION, false);
values.put(AudioColumns.IS_ALARM, false);
values.put(AudioColumns.IS_MUSIC, false);

Uri uri = MediaStore.Audio.Media.getContentUriForPath(file
.getAbsolutePath());

Uri newUri = RingtoneModule.this.getContentResolver()
.insert(uri, values);

RingtoneManager.setActualDefaultRingtoneUri(
RingtoneModule.this, RingtoneManager.TYPE_RINGTONE,
newUri);

When I get to insert I get this exception:

11-17 09:54:51.802: ERROR/DatabaseUtils(379): java.lang.IllegalStateException: Unknown URL: content://media/external/audio/albumart/-1
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.query(MediaProvider.java:1666)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.getAlbumArtOutputUri(MediaProvider.java:2983)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.makeThumbInternal(MediaProvider.java:3192)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.getThumb(MediaProvider.java:3070)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:2029)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1843)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at android.content.ContentProvider$Transport.insert(ContentProvider.java:180)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:175)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at android.os.Binder.execTransact(Binder.java:288)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at dalvik.system.NativeStart.run(Native Method)

I google my a** of for this error but can seem to get anything info about this error.I looked at android source and the problem seems to be that when you dont have album art it generates a url “content://media/external/audio/albumart/-1” and the urlmatcher does not match any of the urls specified and then i throws this error.

URI_MATCHER.addURI("media", "*/audio/albumart", AUDIO_ALBUMART);
URI_MATCHER.addURI("media", "*/audio/albumart/#", AUDIO_ALBUMART_ID);

Does someone have any idea how I can get around that?

  • 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-24T06:26:30+00:00Added an answer on May 24, 2026 at 6:26 am

    I had this error in my application with a handful of users, I finally fixed it though.

    In my application I told the media scanner not to scan my directories by putting a file in the directory called .nomedia I think this might have been confusing the media scanner because I wanted to use a file from within the directory.

    So when set as ringtone/notification/alarm was activated I copied the required sound to a directory called /sdcardpath/ringtones /sdcardpath/notifications /sdcardpath/alarms and then used the same code to set the file from there.

    This is the copy function I made

        public void ringtonemove(String ringtype){
    
    
             String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
             String outpath = sdcard + "/ringtones";
             String path = sdcard + "/multi10/" + Global.currentboard + "/series10";
    
             if (ringtype == "MultiboardRing") {outpath = sdcard + "/ringtones/";}
             if (ringtype == "MultiboardNotif") {outpath = sdcard + "/notifications/";}
             if (ringtype == "MultiboardAlarm") {outpath = sdcard + "/alarms/";}
    
        File in = new File(path, Global.currentsound);
        File out = new File(outpath, ringtype + ".ogg");
        Global.k = outpath + ringtype + ".ogg";
    
    
    
             File folderR = new File(Environment.getExternalStorageDirectory() + "/ringtones");
             File folderN = new File(Environment.getExternalStorageDirectory() + "/notifications");
             File folderA = new File(Environment.getExternalStorageDirectory() + "/alarms");
             if (folderR.exists()); else {folderR.mkdir();}
             if (folderN.exists()); else {folderN.mkdir();}
             if (folderA.exists()); else {folderA.mkdir();}
    
    
    
                         Log.d("Notice", "Copying sound file " + in);
                         try {
                            FileInputStream fis = new FileInputStream(in);
                               int size = fis.available();
                                 byte[] buffer = new byte[size];
                                 fis.read(buffer);
                                 fis.close();
    
                                 FileOutputStream fos = new FileOutputStream(out);
                                 fos.write(buffer);
                                 fos.close();
    
    
    
                        } catch (FileNotFoundException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
    
    
        }
    

    Then I set as ringtone with this code:

     public void function1(int id){
                Toast.makeText(this, "Set as ringtone" , Toast.LENGTH_SHORT).show();
                String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
    
                      String path = sdcard + "/multi10/" + Global.currentboard + "/series10";
    
    
                        ringtonemove("MultiboardRing");
    
                        File k = new File(Global.k);
    
                            ContentValues values = new ContentValues();
                            values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
                            values.put(MediaStore.MediaColumns.TITLE, "MultiboardRing");
                            values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg");
                            values.put(MediaStore.Audio.Media.ARTIST, "Unknown artist");
                            values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
                            values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
                            values.put(MediaStore.Audio.Media.IS_ALARM, false);
                            values.put(MediaStore.Audio.Media.IS_MUSIC, false);
    
                            Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
                            getContentResolver().insert(uri,values);
                            getContentResolver().delete(uri,MediaStore.MediaColumns.TITLE + "=\"" + "MultiboardRing" +"\"", null);
                            Uri newUri = getContentResolver().insert(uri, values);
    
                            RingtoneManager.setActualDefaultRingtoneUri(
                              series10button.this,
                              RingtoneManager.TYPE_RINGTONE,
                              newUri);
    
            }
    

    Hope this helps someone as it took me ages to work this one out

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

Sidebar

Related Questions

I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
I've wrote this simple piece of code. And I have a slight problem with
Some time ago I wrote a little piece of code to ask about on
Recently I wrote a piece of C# code utilizing a Lambda expression: var dynMenu
I'm sorry, but a while ago I wrote a piece of code that was
Hey, I've got this nice little piece of code, much like all the other
I hope in a good manner :-) I wrote this piece of code. What
I wrote a small piece of code that rapidly read and write to a
I have the following piece of code that I wrote in C. Its fairly
I am working on some strange piece of code ,For me its not good

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.