Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AssetManager access = getAssets();
- String DB_PATH = "/data/data/<package name>/databases/";
- byte [] buffer = new byte [1024];
- int length;
- InputStream dbInputStream = null;
- OutputStream dbOutputStream = null;
- //move the db to the designated path
- if ((new File(DB_PATH + "test.db")).exists() == false) {
- File f = new File(DB_PATH);
- if (!f.exists()) {
- f.mkdir();
- }
- }
- try {
- dbInputStream = access.open("test.db");
- dbOutputStream = new FileOutputStream(DB_PATH + "test.db");
- while ((length = dbInputStream.read(buffer)) > 0) {
- dbOutputStream.write(buffer, 0, length);
- }
- dbOutputStream.flush();
- dbOutputStream.close();
- dbInputStream.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(DB_PATH+"test.db", null);
Add Comment
Please, Sign In to add comment