4

バックアップがインストールされた apk を取得したい。プログラムでアプリケーションの .apk ファイルを取得する方法を使用して、apk ファイルを取得します。別のファイルにバックアップしようとすると、

Caused by: java.nio.channels.NonWritableChannelException

ファイルをバックアップするコード:

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();
     }

manifest.xmlにもandroid.permission.WRITE_EXTERNAL_STORAGEを書いています。

4

0 に答える 0