Android : Android SQLite database re-Import

on Saturday, August 16, 2014


in my project i have imported a sqlite database using this..



private void copyDataBase() throws IOException{

InputStream myInput = myContext.getAssets().open(DB_NAME);

String outFileName = DB_PATH + DB_NAME;

OutputStream myOutput = new FileOutputStream(outFileName);

byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}

myOutput.flush();
myOutput.close();
myInput.close();

}


It Works fine. But When I delete the database file from the DDMS File Explorer and try to import it again, the code breaks down.


it says no such file found and create a empty database... Is there any way to overcome this problem?


0 comments:

Post a Comment