問題があります。メインのアクティビティ内に着信音を設定したいのですが、このチュートリアルを読みました:http ://androidgenuine.com/?tag=set-as-ringtone-android 、しかし関数の保存が機能していません。特定のファイルを作成できません。関数がfalseを返します。新しいファイルを作成する部分だけを書き直しましたが、この部分でも機能していません。ここにコードがあります。何が問題なのですか(falseを返し、ファイル以外が作成されました)。
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;
}
}
ご協力いただきありがとうございます