Database version is zero on initial install

Posted by mahesh on Stack Overflow See other posts from Stack Overflow or by mahesh
Published on 2010-06-06T15:22:06Z Indexed on 2010/06/06 15:42 UTC
Read the original article Hit count: 469

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about android

Related posts about sqlite