Created
June 11, 2012 15:24
-
-
Save dimmduh/2910639 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void copyDataBase() throws IOException{ | |
// Path to the just created empty db | |
String outFileName = DB_PATH + DB_NAME; | |
//Open the empty db as the output stream | |
OutputStream myOutput = new FileOutputStream(outFileName); | |
//transfer bytes from the inputfile to the outputfile | |
byte[] buffer = new byte[1024]; | |
int length; | |
//multipart copy | |
//@see http://stackoverflow.com/questions/4391796/big-sqlite-database-in-android-application | |
//@see http://androidsnips.blogspot.com/2010/10/copying-larger-database-files-in.html | |
int parts = 3; | |
for (int i = 1; i <= parts; i++){ | |
InputStream myInput = myContext.getAssets().open(DB_NAME + '.' + i); | |
while ((length = myInput.read(buffer))>0){ | |
myOutput.write(buffer, 0, length); | |
} | |
myInput.close(); | |
} | |
//Close the streams | |
myOutput.flush(); | |
myOutput.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment