ファイルを外部ストレージの一時ディレクトリに保存できるようにする必要があります。保存しているファイルは、アプリのR.rawディレクトリです。
ここではこの例を使用しました。 AndroidのSDカードにRawファイルを移動する
問題は1です。アプリは必要な.m4aファイルを読み取っているようです(ここで間違ったバイトを読み取る可能性があります)。2.ファイルが/tmpdirに保存されるとき、ファイルサイズは完全に間違っています。たとえば、1つのファイルが30kbから300kbになり、別のファイルが25kbから.25kbになります。
助言がありますか
public String saveAs(int ressound, String whipName){
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
Log.i("saveas", "did not save1");
//return false;
}
String path= Environment.getExternalStorageDirectory().getAbsolutePath()+"/tmp/.pw2";
String filename="/"+whipName+".m4a";
Log.i("path", "file path is " + path);
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
Log.i("saveas", "did not save2");
//return false;
} catch (IOException e) {
// TODO Auto-generated catch block
Log.i("saveas", "did not save3");
//return false;
}
File k = new File(path, filename);
return k.getAbsolutePath();
}