RingTone Not Set?
<p>I have 51 mp3 file in raw folder I want to set these as a default ringtone,on which user click.Regarding that I firstly transfer all mp3 file into sd-card after that execute method 
of setting ringtone my code is as please guide me where it is wrong I have seen solution of stack overflow but that's not work for me.</p>

<pre><code>    public boolean saveAsRigTone(int ressound) {
    byte[] buffer = null;
    int res = objmap.get(new Integer(ressound)).intValue();
    InputStream fIn = getBaseContext().getResources().openRawResource(res);
    int size = 0;

    try {
        size = fIn.available();
        buffer = new byte[size];
        fIn.read(buffer);
        fIn.close();
    } catch (IOException e) {
        return false;
    }
    String myringtone = Environment.getExternalStorageDirectory()
            .toString() + File.separator + "ghost";
    if (!new File(myringtone).isDirectory()) {
        new File(myringtone).mkdir();
    }
    String ringtone =myringtone+"/sound.mp3";
    FileOutputStream save;
    try {
        save = new FileOutputStream(ringtone);
        save.write(buffer);
        save.flush();
        save.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }

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


    File k = new File(myringtone,"sound.mp3");

    ContentValues values = new ContentValues();
    values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
    values.put(MediaStore.MediaColumns.TITLE, "exampletitle");
    values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
    values.put(MediaStore.MediaColumns.SIZE, k.length());
    values.put(MediaStore.Audio.Media.ARTIST, "cssounds ");
    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
    /*this.getContentResolver()
            .insert(MediaStore.Audio.Media.getContentUriForPath(k
                    .getAbsolutePath()), values);*/
     Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
      Uri newUri = this.getContentResolver().insert(uri, values);

     try {
           RingtoneManager.setActualDefaultRingtoneUri(MainActivity.this, RingtoneManager.TYPE_RINGTONE, newUri);
       } catch (Throwable t) {
           Log.d("check", "catch exception");
       }

    return true;
}
</code></pre>
