itzdiceman
Lurker
I am attempting to allow a user to save raw audio from my app to their SD card. Then in turn select that audio as a ring tone.
My code:
------------------------------------------------------
InputStream fIn = getBaseContext().getResources().openRawResource(clipID);
int size = fIn.available();
byte[] buffer = new byte[size];
fIn.read(buffer);
fIn.close();
File rtNew = new File(
"/sdcard/XYZ/Ringtones/"
+ ((Button) findViewById(buttonID)).getText()
+ ".ogg");
FileOutputStream rtFOS = new FileOutputStream(rtNew);
rtFOS.write(buffer);
rtFOS.flush();
rtFOS.close();
-------------------------------------------------------
buttonID is the int from R.id.buttonX and clipID is R.raw.clipX. The directory /sdcard/XYZ/Ringtones has been created previously in the application. I can confirm that the directory and the file are created using ASTRO.
I've tried several variations on this code(which is why rtNew is a separate object). Including using /sdcard/ringtones and using all variations of case sensitive directories and file names.
No matter what I try I cannot get the audio clip to appear in the "Settings->Sound & display->Phone ringtone" list.
Here's the EXCEPTION:
-I allow my app to create the directories and the file
-confirm with ASTRO that they've been created
-confirm that it IS NOT in the ring tones list
-rename the file with ASTRO without changing the file name
-then the file appears in the ring tones list
This exception adds the file to the ringtones list even in a directory /sdcard/XYZ/ringtones. I've also tried rtNew.renameTo after writing the file. This did not work either.
Has anyone experienced this or have a solution?
Thanks.
My code:
------------------------------------------------------
InputStream fIn = getBaseContext().getResources().openRawResource(clipID);
int size = fIn.available();
byte[] buffer = new byte[size];
fIn.read(buffer);
fIn.close();
File rtNew = new File(
"/sdcard/XYZ/Ringtones/"
+ ((Button) findViewById(buttonID)).getText()
+ ".ogg");
FileOutputStream rtFOS = new FileOutputStream(rtNew);
rtFOS.write(buffer);
rtFOS.flush();
rtFOS.close();
-------------------------------------------------------
buttonID is the int from R.id.buttonX and clipID is R.raw.clipX. The directory /sdcard/XYZ/Ringtones has been created previously in the application. I can confirm that the directory and the file are created using ASTRO.
I've tried several variations on this code(which is why rtNew is a separate object). Including using /sdcard/ringtones and using all variations of case sensitive directories and file names.
No matter what I try I cannot get the audio clip to appear in the "Settings->Sound & display->Phone ringtone" list.
Here's the EXCEPTION:
-I allow my app to create the directories and the file
-confirm with ASTRO that they've been created
-confirm that it IS NOT in the ring tones list
-rename the file with ASTRO without changing the file name
-then the file appears in the ring tones list
This exception adds the file to the ringtones list even in a directory /sdcard/XYZ/ringtones. I've also tried rtNew.renameTo after writing the file. This did not work either.
Has anyone experienced this or have a solution?
Thanks.