没有你的滑板猫,这只是在黑暗中拍摄。
您可以尝试以另一种方式检查文件的存在 :
private static boolean checkDataBase(String dbname) {
SQLiteDatabase checkDB = null;
boolean exist = false;
try {
String db = MAIN_DB_PATH + dbname;
checkDB = SQLiteDatabase.openDatabase(db, null,
SQLiteDatabase.OPEN_READONLY);
} catch (SQLiteException e) {
Log.v("db log", "database does t exist");
}
if (checkDB != null) {
exist = true;
checkDB.close();
}
return exist;
}
如果 db 不存在的话, 使用另一种方法复制 db :
private static void copyDataBase(String dbname) throws IOException {
InputStream myInput = mCtx.getAssets().open(dbname);
String outFileName = MAIN_DB_PATH + dbname;
OutputStream myOutput = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
myOutput.flush();
myOutput.close();
myInput.close();
}