Skip to content

Instantly share code, notes, and snippets.

@codeachange
Created April 27, 2014 06:38
Show Gist options
  • Save codeachange/11338995 to your computer and use it in GitHub Desktop.
Save codeachange/11338995 to your computer and use it in GitHub Desktop.
android copy sqlite database
File dbPath = getDatabasePath("taobaoclient.db");
if (!dbPath.exists()) {
try {
InputStream is = getAssets().open("databases/taobaoclient.db");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
FileOutputStream fos = new FileOutputStream(dbPath);
fos.write(buffer);
fos.close();
}catch (Exception e){
Log.e("Fck", e.getMessage());
}
}
try{
db = SQLiteDatabase.openDatabase(dbPath.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE);
}catch(Exception e){
Log.e("fck", e.getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment