bootanimation.zip
という名前のファイルをフォルダにコピーしたいので、これを書いても動作しません!Javaを使用してAndroidでファイルをコピーできませんか?
class CopyFile {
void CopyFileUsingStream(String sourc, String dest) throws IOException, InterruptedException {
File system = new File("/system");
File sysboot = new File("/system/media/bootanmimation.zip");
FileInputStream source = null;
FileOutputStream destination = null;
system.setWritable(true,false);
sysboot.setWritable(true,false);
while (!system.canWrite()){
Log.v("SYSW","Non scrivibile");
}
while (!sysboot.canWrite()){
Log.v("BOOTW","Non scrivibile");
}
try {
source = new FileInputStream(new File(sourc));
destination = new FileOutputStream(new File(dest));
IOUtils.copy(source, destination);
} finally {
IOUtils.closeQuietly(source);
IOUtils.closeQuietly(destination);
}
}
私はあなたが根なしにこれを達成することはできません
final CopyFile cp = new CopyFile();
apply = (Button) findViewById(R.id.apply);
apply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String dststring = "/system/media/bootanimation.zip";
String src = choosedFileLocation;
try {
cp.CopyFileUsingStream(src,dststring);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
あなたはrootアクセス権を持っていますか? – Fildor
@Fildorはい私は –
を持っています。Arasthelによれば、rootプロビジョルであっても、/ systemパーティションをrwパーミッションで再マウントする必要があります。 –