我正在尝试导入我存储在SD卡上的数据库,我用它作为备份来替换当前数据库,如果我想恢复某些东西但是当我尝试导入时我得到{{1} }
错误
NonWritableChannelException
这是我用来导入的方法
12-15 12:27:48.190: W/System.err(13599): java.nio.channels.NonWritableChannelException
12-15 12:27:48.190: W/System.err(13599): at java.nio.FileChannelImpl.checkWritable(FileChannelImpl.java:85)
12-15 12:27:48.190: W/System.err(13599): at java.nio.FileChannelImpl.transferTo(FileChannelImpl.java:399)
12-15 12:27:48.190: W/System.err(13599): at com.tyczj.bowling.Bowlers$ImportData.importGames(Bowlers.java:944)
12-15 12:27:48.200: W/System.err(13599): at com.tyczj.bowling.Bowlers$ImportData.doInBackground(Bowlers.java:914)
12-15 12:27:48.200: W/System.err(13599): at com.tyczj.bowling.Bowlers$ImportData.doInBackground(Bowlers.java:1)
12-15 12:27:48.200: W/System.err(13599): at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-15 12:27:48.200: W/System.err(13599): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
12-15 12:27:48.210: W/System.err(13599): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-15 12:27:48.210: W/System.err(13599): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-15 12:27:48.210: W/System.err(13599): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-15 12:27:48.210: W/System.err(13599): at java.lang.Thread.run(Thread.java:856)
这个错误是什么意思,我之前从未有过这个错误,如何正确导入数据库文件
答案 0 :(得分:6)
您的“收件人”频道应该是文件输出流,因为您要写入(不读取)此文件:
FileChannel toChannel = new FileOutputStream(oldDB).getChannel();