onCreate should always build your the database for your current version (say 5)
onUpgrade will be called asking your to upgrade your database. It can be called with any version less than your current version so you have to cope with upgrading from: 1 -> 5 2 -> 5 3 -> 5 4 -> 5 The way I do this (to keep the amout of testing under control) is to upgrade through all version in one pass (think drop through case statement): 1 -> 2 -> 3 -> 4 -> 5 So i never upgrade from say 3 -> 5 but always do 3 -> 4 -> 5 It takes a bit longer to run but this tesing is a lot less /Richard On Jul 9, 10:58 am, martinlong1978 <[email protected]> wrote: > Hi, > > The documentation does not make the interation between onUpgrade() and > onCreate() clear. > > When implementing onCreate() should this create the database at > version 1, assuming that onUpgrade will apply all of the patches to > bring it up to version x (lets say version 5 for example)? Or should > onCreate build the latest version of the database, and onUpgrade is > only used to upgrade legacy clients. > > I kind of prefer the first, because it effectively means that the same > SQL is executed for everybody. Whereas the second options means that > there is a potential for onCreate to build something slightly > different to the succession of patches built by onUpgrade. > > I can always make onCreate call into onUpgrade, however, this is the > kind of implementation detail that should go into the javadocs... > please update! > > Thanks > > Martin -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

