Last active
August 29, 2015 14:19
-
-
Save n0m0r3pa1n/cc09d3b931f010ee0ccf to your computer and use it in GitHub Desktop.
This file contains 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 static final String DATABASE_NAME = "BGHISTORY_v3"; | |
private static final String DATABASE_PATH = "/data/data/com.nmp90.bghistory/databases/"; | |
private void copyDataBase() throws IOException { | |
//Open your local db as the input stream | |
InputStream myInput = myContext.getAssets().open(DATABASE_NAME); | |
// Path to the just created empty db | |
String outFileName = DATABASE_PATH + DATABASE_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; | |
while ((length = myInput.read(buffer)) > 0) { | |
myOutput.write(buffer, 0, length); | |
} | |
//Close the streams | |
myOutput.flush(); | |
myOutput.close(); | |
myInput.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment