Problem setting media file as ringtone
<p>I am trying to set an audio file from my resources as the user's ringtone when long clicked. I am having trouble doing this -- I do not get a FC, but when I get a call, it is a silent ringtone. I go into the settings and select to set ringtone, and I can see the name of the file I created, but it doesn't work. </p>

<p>This is my java code:</p>

<pre><code>String filepath = "/sdcard/fightsong.mp3";
File ringtoneFile = new File(filepath);

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setContentView(R.layout.long_click_test);

    ContentValues content = new ContentValues();
    content.put(MediaStore.MediaColumns.DATA, ringtoneFile.getAbsolutePath());
    content.put(MediaStore.MediaColumns.TITLE, "Fight Song");
    content.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
    content.put(MediaStore.Audio.Media.IS_RINGTONE, true);


    Log.i(TAG, "the absolute path of the file is :"+ringtoneFile.getAbsolutePath()); 
    Uri uri = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile.getAbsolutePath()); 
    Uri newUri = this.getContentResolver().insert(uri, content); 
    Uri ringtoneUri = newUri; 
    Log.i(TAG,"the ringtone uri is :"+ringtoneUri); 
    RingtoneManager.setActualDefaultRingtoneUri(this,RingtoneManager.TYPE_RINGTONE,newUri); 
</code></pre>

<p>This is is the code for onLongClick and the bit that passes it off the the code above:</p>

<pre><code>private OnLongClickListener onLongImageClick = new OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
            case R.id.boston_college_imageview:
                SetRingtone(R.raw.acc_boston_college);
            break;
        }
        return true;
    }
};

private void SetRingtone(int soundID) {
    Intent myIntent = new Intent();
    myIntent.setClassName("com.carboni.fightsongs", "com.carboni.fightsongs.SetRingtone");
    myIntent.putExtra("com.carboni.fightsongs.FILE_RES_ID", soundID);
    startActivity(myIntent);
}
</code></pre>

<p>And I have the permissions and Java set in the Manifest.</p>

<p>This is my Logcat error: </p>

<pre><code> 07-26 16:32:38.152: ERROR/Database(309): Error inserting album_id=8 title=Fight Song title_key=Q7Q=Q9Q;QSQQQQIQGQ9Q mime_type=audio/mp3 date_added=1311712358 _display_name=fightsong.mp3 is_ringtone=true artist_id=1 _data=/sdcard/fightsong.mp3
07-26 16:32:38.152: ERROR/Database(309): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
07-26 16:32:38.152: ERROR/Database(309):     at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
07-26 16:32:38.152: ERROR/Database(309):     at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
07-26 16:32:38.152: ERROR/Database(309):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1582)
07-26 16:32:38.152: ERROR/Database(309):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
07-26 16:32:38.152: ERROR/Database(309):     at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:1940)
07-26 16:32:38.152: ERROR/Database(309):     at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1759)
07-26 16:32:38.152: ERROR/Database(309):     at android.content.ContentProvider$Transport.insert(ContentProvider.java:198)
07-26 16:32:38.152: ERROR/Database(309):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
07-26 16:32:38.152: ERROR/Database(309):     at android.os.Binder.execTransact(Binder.java:320)
07-26 16:32:38.152: ERROR/Database(309):     at dalvik.system.NativeStart.run(Native Method)
07-26 16:32:38.156: INFO/CFFS(32664): the ringtone uri is :null
</code></pre>
