In some books and on the Internet, I see how these method calls are executed after the database is created:
db.setLocale(Locale.getDefault()); db.setLockingEnabled(true); db.setVersion(DB_VERSION);
Why is this done? As far as I can tell, after creating a new database, the system adds a table named android_metadata with one field named locale, and this table has one row with the locale field set to "En_US". Now I believe that the column has this value because I use the USA Phone, and if I used the phone from another region, then the locale field will be set accordingly. Can anyone confirm this? I assume that the setLocale method will only be useful if you are installing a pre-created database on your phone, and then want to change the locale to suit the locale of your phone. Sounds right?
The documentation for setLockingEnabled states that the default value is true, so there is no need to make this call, right?
Finally, what about calling setVersion? I cannot find a table that contains this information, so I assume that the database file itself somewhere stores the version number. Therefore, when I create a database that requires that you already specify the version number in the SQLiteOpenHelper constructor call, there is no setVersion in the call. Again, perhaps this method exists for installing a pre-installed database on the device, and then you want to change the version of the database (although I canβt think of when it makes sense).
Thank you for understanding!
android database sqlite
gdoten
source share