在代码中通过函数extractDatabase()解压Assets目录下的数据库dump.bin文件,我想知道如何对这个数据库进行编辑和查看?
private void extractDatabase() throws IOException {
final ZipInputStream zipInputStream = new ZipInputStream(DatabaseHelper.sAppContext.getAssets().open("dump.bin"));
if (zipInputStream.getNextEntry() != null) {
final byte[] array = new byte[1024];
final File file = new File(getInstance().mDbDir);
if (!file.exists()) {
file.mkdirs();
}
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(this.mDbDir + "dump.bin"), 1024);
while (true) {
final int read = zipInputStream.read(array, 0, 1024);
if (read == -1) {
break;
}
bufferedOutputStream.write(array, 0, read);//
}
bufferedOutputStream.flush();
bufferedOutputStream.close();
}
zipInputStream.close();
}
一只名叫tom的猫
相关分类