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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:58:30+00:00 2026-06-09T10:58:30+00:00

I have a problem, I want to set a ringtone inside my main acivity,

  • 0

I have a problem, I want to set a ringtone inside my main acivity, I read this tutorial: http://androidgenuine.com/?tag=set-as-ringtone-android , but function save is not working, to be more specific I can’t create a file, function is returning false. I write again only a part with creating new File but even this part is not working, here is the code, what’s wrong (it;s returning false and non file was created) ?

    public boolean save2(int ressound){

    String path="/sdcard/sounds/";
    String filename="ring.mp3";
    byte[] buffer = null;
    FileOutputStream save;
    InputStream fIn = getBaseContext().getResources().openRawResource(ressound);
    int size=0;
    try {
        size=fIn.available();
        buffer = new byte[size];
        fIn.read(buffer);
        fIn.close();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    try {
        save = new FileOutputStream(path+filename);
        save.write(buffer);
        save.flush();
        save.close();
        return true;
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
    }
}

Thanks for your help

  • 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-09T10:58:32+00:00Added an answer on June 9, 2026 at 10:58 am

    I can only guess that directory you specified might not exist or that you do not have the appropriate permission set in your manifest.

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    

    You should be constructing it with the following from documentation found at

    http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

    File path = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");
    
    // Make sure the Pictures directory exists.
    path.mkdirs();
    

    You also must check if the external storage is even mounted.

    String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state)) {
            mExternalStorageAvailable = mExternalStorageWriteable = true;
        } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
            mExternalStorageAvailable = true;
            mExternalStorageWriteable = false;
        } else {
            mExternalStorageAvailable = mExternalStorageWriteable = false;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem when want read object with where (double variable) this is my
Suppose we have the following problem - we want to read a set of
i have a problem, i want set text of a UILabel or UItextView or
I have this problem: I want to generate a new source code file from
I have problem with HTTP headers, they're encoded in ASCII and I want to
I have a problem: I want to set the image of my grid through
I am pretty new to TFS so I have this problem when I want
I have a problem that I want to set the position of text as
I have the following problem... I want to set a session variable when clicking
I have problem with this query DECLARE @INPUT INT SET @INPUT = 12345 ;

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.