I want to get backup installed apk. by using How to get the .apk file of an application programatically and I get the apk File. and when I try to take backup to another file I get
Caused by: java.nio.channels.NonWritableChannelException
code to get backup the file:
File sourceFile = new File(app.publicSourceDir);
File backupFile = new File(Environment.getExternalStorageDirectory(), "SoundRecorder.apk");
if(!backupFile.exists())
backupFile.createNewFile();
if(sourceFile.exists()) {
FileChannel src = new FileInputStream(sourceFile).getChannel();
FileChannel dst = new FileInputStream(backupFile).getChannel();
dst.transferFrom(src, 0, src.size()); <--here I get the exception
src.close();
dst.close();
}
I write android.permission.WRITE_EXTERNAL_STORAGE in manifest.xml also.