Android SQLite database locale, locking, and version

Posted by gdoten on Stack Overflow See other posts from Stack Overflow or by gdoten
Published on 2010-04-01T17:51:17Z Indexed on 2010/04/01 17:53 UTC
Read the original article Hit count: 385

Filed under:
|
|

In some books and online I see these method calls being made after a 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 that table has one row with the locale field set to "en_US". Now I assume the column has that value because I am using a U.S. phone, and if I were using a phone from a different region then the locale field would be set appropriately. Can anyone confirm this? I'm guessing that the setLocale method would only be useful in the case that you install a pre-built database onto a phone and then want to change the locale to match the phone's locale. Sound right?

The documentation for setLockingEnabled says it defaults to true so there's no need to make that call, right?

Lastly, what's with the call to setVersion? I can't find a table that contains this information so I've been assuming that the database file itself stores the version number somewhere. So when I create a database, which requires you to have already specified the version number in the call to the SQLiteOpenHelper constructor, there's no point in calling setVersion. Again, perhaps this method exists for the case of installing a pre-built database to a device and you then wish to change the database's version (though I can't think of when doing this would make sense).

Thanks for any insight!

© Stack Overflow or respective owner

Related posts about sqlite

Related posts about android