copy it to data/data/com.example.android/databases folder using following code
- Code: Select all
private void copyDataBase() throws IOException{
//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);
// 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;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}
Problem is if Database is 2 MB or greater. It exceeds the size and throws an exception. Is there an example online regarding where to place prepopulated big databases? Any help is highly apprecaited.
I followed following tutorial for copying database in case someone is interested.
http://www.reigndesign.com/blog/using-y ... lications/