私のアプリからユーザーのSDカードに着信音を転送しようとすることを目指しています
しかし、別の着信音を保存しようとすると、関数は古い着信音と新しい着信音を同じ mp3 ファイルとして保存します
初めて lol.mp3 を保存したときのように、hora.mp3 のような別のものを保存すると、その作業が機能します。
mora.mp3 と lol.mp3 を hora.mp3 の同じファイルとして保存します。この問題を修正する方法を教えてください。
public boolean saveas(int ressound , String ringname , Boolean isringtone , Boolean isnotificatoion ){
byte[] buffer=null;
InputStream fIn = getBaseContext().getResources().openRawResource(ressound);
int size=0;
try {
size = fIn.available();
buffer = new byte[size];
fIn.read(buffer);
fIn.close();
} catch (IOException e) {
// TODO Auto-generated catch block
return false;
}
String path="/sdcard/Islamyat/";
String filename="mysound"+".mp3";
boolean exists = (new File(path)).exists();
if (!exists){new File(path).mkdirs();}
FileOutputStream save;
try {
save = new FileOutputStream(path+filename);
save.write(buffer);
save.flush();
save.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
return false;
} catch (IOException e) {
// TODO Auto-generated catch block
return false;
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename)));
File k = new File(path, filename);
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, ringname);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
values.put(MediaStore.Audio.Media.ARTIST, "yappname");
values.put(MediaStore.Audio.Media.IS_RINGTONE, isringtone);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, isnotificatoion);
values.put(MediaStore.Audio.Media.IS_ALARM, false);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);
//Insert it into the database
Uri newUri= this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);
RingtoneManager.setActualDefaultRingtoneUri(
this,
RingtoneManager.TYPE_RINGTONE,
newUri
);
return true;
}