No, onUpgrade doesn't delete any data, tables, or databases.

It's just a callback in your code that's called by Android when the "desired" database version doesn't match the "existing" database version.

Your callback can do whatever it needs to bring the database schema up to date - typically, adding columns or tables.

So if your code just does "ALTER TABLE ADD COLUMN", you don't need to do anything special to preserve existing data.

-- Kostya

22.10.2010 16:56, Alok Kulkarni пишет:
Yeah ill do my best.. My code is too complicated right now... :P
One more thing i need to confirm.. After upgrade , all the old
databases are deleted right.. So i need to backup all the tables in
the onUpgrade and recreate new ones .. Right ?

On Fri, Oct 22, 2010 at 6:20 PM, Kostya Vasilyev<kmans...@gmail.com>  wrote:
Sounds like this could be it.

Can't you just go through SQL open helper for all code paths?

-- Kostya

22.10.2010 16:37, Alok Kulkarni пишет:
No. Actually i am accessing another table from my databases at the
same time from another thread while onUpgrade is being called.So i
think thats where the problem lies.But i need to figure out a way so
that i access the SQL tables after the on Upgrade function completes.

On Fri, Oct 22, 2010 at 5:58 PM, Kostya Vasilyev<kmans...@gmail.com>
  wrote:
AFAIK, there is nothing special, except:

- onUpgrade may take some time to run
- the tables are not updated until after onUpgrade is done

Are you accessing the database in any way bypassing your SQL open helper?

Is this what you mean by "

At the start of the application ,
i initialize all the databases and access columns from the required
tables

"
?

If you're relying on SQL open helper and its onUpgrade, then that should
be
the only way you're accessing the database.

-- Kostya

22.10.2010 15:14, Alok Kulkarni пишет:
Hi,
I have multiple databases in my app.At the start of the application ,
i initialize all the databases and access columns from the required
tables.What i did is , for one of the databases  i incremented the
version of the DB. So now i have started getting error of " No Such
table say ABCD while compiling " query.This table is in another DB
than the updated DB. I dont have any code in the onUpgrade right now..
Is there any thing thats striking anyone why this behavior is
happening? Is there anything that happens in the onUpgrade method that
causes all the DBs to be inaccessable temporarily. I am saying this
because if i place a breakpoint in onUpgrade and debug , then i wait
for a few seconds on the 1st stmt in onUpgrade and then everything
works fine...

--
Kostya Vasilyev -- WiFi Manager + pretty widget --
http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
Kostya Vasilyev -- WiFi Manager + pretty widget --
http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to