Database version is zero on initial install
- by mahesh
I have released an app (World Time) with initial database. Now i want to update the app with a database upgrade.
I have put in the upgrade code in OnUpgrade() and checking for the newVersion. But it was not being called in my local testing...
So i put in the debug statement to get the database version and it is zero .
Any idea why it is not being versioned ?
Following is the code to copy the database from my Assets folder ...
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();
--
Mahesh
http://android.maheshdixit.com