有没有办法导出可写数据库?我需要在 Visual Studio 应用程序中使用从手机导出的数据库作为系统的一部分。我知道这很糟糕,但这是我唯一可以做的项目。这是我用来从SQLiteImporterExporter库中导出数据库的代码
public void exportDataBase(String path) {
InputStream myInput = null;
OutputStream myOutput = null;
try {
String inFileName = DB_PATH + DB_NAME;
myInput = new FileInputStream(inFileName);
String outFileName = path + DB_NAME;
myOutput = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
if (exportListener != null)
exportListener.onSuccess("Successfully Exported");
} catch (Exception e) {
if (exportListener != null)
exportListener.onFailure(e);
} finally {
try {
// Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
} catch (Exception ex) {
if (exportListener != null)
exportListener.onFailure(ex);
}
}
}
江户川乱折腾
相关分类