Androidの内部メモリからSDカードの既存のディレクトリにプログラムでファイルを移動しようとしています。
私は2つの方法を試しました。最初のものでは、File.renameToを使用しました。
String destName = externalDirPath + File.separatorChar + destFileName;
File originFile = new File(cacheDirPath + File.separatorChar + originalfileName);
originFile.renameTo(new File(destName));
もう1つは、Runtime.getRuntime()を使用しました。
Process p = Runtime.getRuntime().exec("/system/bin/sh -");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
String command = "cp " + cacheDirPath + "/" + originalfileName+ " " + externalDirPath + "/" + destFileName+ "\n";
os.writeBytes(command);
それらの両方でそれは動作しません..
何か提案はありますか?