我使用本教程将数据库文件包含到我的 android 应用程序中。它在我的 HTC Decire HD 上运行良好。我想在模拟器上运行它,看看平板电脑的布局是否好看。不幸的是,该应用程序因错误而失败。
private void copyDataBase() throws IOException{
//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);
// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;
//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){ <------ HERE, at first iteration
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}
此错误的消息只是“空”,仅此而已。这可以解决吗?