db数据库的处理
final String DB_DESTINATION = "/data/data/YOUR_PACKAGE_NAME/databases/MyDatabaseFile.db";?
?
// Check if the database exists before copying?
boolean initialiseDatabase = (new File("DB_DESTINATION")).exists();?
if (initialiseDatabase == true) {?
?
? ? // Open the .db file in your assets directory?
? ? InputStream is = getContext().getAssets().open("MyDatabaseFile.db");?
?
? ? // Copy the database into the destination?
? ? OutputStream os = new FileOutputStream(DB_DESTINATION);?
? ? byte[] buffer = new byte[1024];?
? ? int length;?
? ? while ((length = is.read(buffer)) > 0){?
? ? ? ? os.write(buffer, 0, length);?
? ? }?
? ? os.flush();?
?
? ? os.close();?
? ? is.close();?
}?