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 6114661

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:00:02+00:00 2026-05-23T15:00:02+00:00

I am trying set a ringtone through my android application. I tried with this

  • 0

I am trying set a ringtone through my android application. I tried with this code

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    String filepath ="/sdcard/sound.mp3";
    File ringtoneFile = new File(filepath);

    ContentValues content = new ContentValues();
    content.put(MediaStore.MediaColumns.DATA,ringtoneFile.getAbsolutePath());
    System.out.println(ringtoneFile.getAbsolutePath()+"+++++++++++++++++++++++++");
    content.put(MediaStore.MediaColumns.TITLE, "chinnu");
    content.put(MediaStore.MediaColumns.SIZE, 215454);
    content.put(MediaStore.MediaColumns.MIME_TYPE, "sound.mp3");
    content.put(MediaStore.Audio.Media.ARTIST, "Madonna");
    content.put(MediaStore.Audio.Media.DURATION, 230);
    content.put(MediaStore.Audio.Media.IS_RINGTONE, true);
    content.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
    content.put(MediaStore.Audio.Media.IS_ALARM, false);
    content.put(MediaStore.Audio.Media.IS_MUSIC, false);


    //Insert it into the database
    String TAG="";
    Log.i(TAG, "the absolute path of the file is :"+
    ringtoneFile.getAbsolutePath());
    Uri uri = MediaStore.Audio.Media.getContentUriForPath(
    ringtoneFile.getAbsolutePath());
    Uri newUri = Context.getContentResolver().insert(uri, content);
    ringtoneUri = newUri; 
   Log.i(TAG,"the ringtone uri is :"+ringtoneUri);
   RingtoneManager.setActualDefaultRingtoneUri(context,
   RingtoneManager.TYPE_RINGTONE,newUri);


}
}

But I get the error: context cannot be resolved to a type. What does this mean? I am a beginner with android development. I set write_external_storage permission also.

What more do I have to do to run this application successfully?
Thanks in advance

  • 0 0 Answers
  • 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-23T15:00:04+00:00Added an answer on May 23, 2026 at 3:00 pm
        String filepath ="/sdcard/Fast_N_Furious_2009.mp3";
        File ringtoneFile = new File(filepath);
    
        ContentValues content = new ContentValues();
        content.put(MediaStore.MediaColumns.DATA,ringtoneFile.getAbsolutePath());
        content.put(MediaStore.MediaColumns.TITLE, "chinnu");
        content.put(MediaStore.MediaColumns.SIZE, 215454);
        content.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
        content.put(MediaStore.Audio.Media.ARTIST, "Madonna");
        content.put(MediaStore.Audio.Media.DURATION, 230);
        content.put(MediaStore.Audio.Media.IS_RINGTONE, true);
        content.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
        content.put(MediaStore.Audio.Media.IS_ALARM, false);
        content.put(MediaStore.Audio.Media.IS_MUSIC, false);
    
    
        //Insert it into the database
        Log.i(TAG, "the absolute path of the file is :"+
        ringtoneFile.getAbsolutePath());
        Uri uri = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile.getAbsolutePath());
        //Uri newUri = context.getContentResolver().insert(uri, content);
        Uri newUri = getContentResolver().insert(uri, content); 
        String ringtoneUri = newUri.toString();
    
        Log.i(TAG,"the ringtone uri is :"+ringtoneUri);
        RingtoneManager.setActualDefaultRingtoneUri(getBaseContext(),RingtoneManager.TYPE_RINGTONE,newUri);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a way to set a new default ringtone by code
Trying to set RowHeight like this(in code): dgvTruckAvail.RowTemplate.Height = 48; Doesnt' work. I also
Trying to set this label to red I've got the following class: .redErrorText {
I´m trying to set a cell of type System.Int32 in a DataSet by code,
Trying to set up the svn commit with trac using this script. It is
Trying to set up a new spring project and im having this issue where
Trying to set up a project but fail at Autowiring objects through Spring. package
Hi I'm trying to get files in my res/raw folder of my android application
Trying to set this textbox <%= Html.TextBoxFor(m => m.IndicationCalculatorNewGroupName, new {propertyName = IndicationCalculatorNewGroupName, onchange
When trying to set Context attributes like so: void init() { String testing =

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.