when you request a new or existing database you can provide a number
(version of the db schema you are using)

you should keep track of this, as it will be passed to your upgrade handler.


On Mon, Jan 5, 2009 at 1:51 PM, Jay-andro <jayan...@gmail.com> wrote:

>
> Thanks all, for bringing the SQLiteOpenHelper.OnUpgrade method to my
> attention. Reading up on it, I'm not clear on a couple of things:
>
> - When exactly does it fire - when a new version of the app is
> installed, or when the new app first tries to open the database, or
> when the new app tries to create a database when one already exists?
> - For this to work, do we need to call SQLiteDatabase.setVersion when
> we create the database or does the version get set by default to the
> appversion?
> - When the onUpgrade(SQLiteDatabase db, int oldVersion, int
> newVersion) method fires, it receives the database version in
> oldVersion and the appversionname (from manifest file) in newVersion?
> is this correct?
>
> thanks in advance
> Jay
>
> On Jan 4, 7:39 pm, "shaunke...@gmail.com" <shaunke...@gmail.com>
> wrote:
> > Are you using a class that extends SQLiteOpenHelper to open your DB.
> > You should be able to specify a version number then override the
> > onUpgrade method in your SQLiteOpenHelper to update your db from
> > earlier versions.
> >
> > See:
> http://code.google.com/android/reference/android/database/sqlite/SQLi...
> > and look at the NotePad tutorial.
> >
> > On Jan 4, 6:45 pm,Jay-andro<jayan...@gmail.com> wrote:
> >
> > > I have an app that creates an sqllite database on first-use, if one
> > > doesn't already exist. Recently I released a new version of the app,
> > > and all of a sudden several users are complaining of erros that I
> > > didnt encounter in my testing. In my development I always installed
> > > using adb over usb, which in turn requires uninstall the older version
> > > first. So the database was always created anew on first-use of the new
> > > version. But I suspect my existing users are doing an in-place install
> > > on top of their old version, in which case the old db is incompatible
> > > with the new one.
> >
> > > So my questions are:
> > > - Does the Market app allow you to install a new version "on top of"
> > > an old one, without requiring an uninstall first (unlike adb)?
> > > - If an in-place upgrade is supported but the database is not dropped,
> > > the question arises what else is not deleted? Resources, preferences,
> > > manifest? I suspect there would be major havoc if these things werent
> > > completely removed & replaced by the new version.
> >
> > > I am now contemplating adding a preference which will indicate to the
> > > app what version of my db it needs and use this on first-use to
> > > determine if I need to drop and recreate the database or just use the
> > > old db.
> >
> > > Any thoughts?
> >
>

--~--~---------~--~----~------------~-------~--~----~
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