Android 尝试获取备份apk文件时发生java.nio.channels.NonWritableChannelException

Android 尝试获取备份apk文件时发生java.nio.channels.NonWritableChannelException,android,Android,我想安装备份apk。通过使用H和我得到apk文件。当我尝试备份到另一个文件时 Caused by: java.nio.channels.NonWritableChannelException 获取备份文件的代码: File sourceFile = new File(app.publicSourceDir); File backupFile = new File(Environment.getExternalStorageDirectory(), "SoundRecorder.apk"); i

我想安装备份apk。通过使用H和我得到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();
     }
File sourceFile=新文件(app.publicSourceDir);
File backupFile=新文件(Environment.getExternalStorageDirectory(),“SoundRecorder.apk”);
如果(!backupFile.exists())
backupFile.createNewFile();
if(sourceFile.exists()){
FileChannel src=newfileinputstream(sourceFile).getChannel();
FileChannel dst=新的FileInputStream(backupFile).getChannel();

DST.TestOn(SRC,0,SRC,siz());您正在使用FieldPixFielts作为源代码:<代码> DST<代码>代码>文件通道< /代码>。考虑尝试FieleOutsFipe代替,它更可能以写模式打开它的通道。@ Jens:非常感谢Jens……U'R真的是天才……我的问题是通过编写FielOutPoStutsto DST来解决的。