Android Sqlite Locking

Android Sqlite Locking

touchlabblog:

Recently I’ve been doing quite a bit of work with the Android Sqlite database.  Mostly with the android piece of ormlite.

The Android examples cover some basic Sqlite usage, but they really don’t go into depth with regards to proper usage patters, and more importantly, improper usage patters.  Most examples and documentation is slated towards using very basic database queries, and beyond that, creating a ContentProvider.  What never really seems to be covered is stuff like:

  • Where do you create and store your SQLiteOpenHelper instances?
  • How many should you have?
  • Are there any concerns when accessing the database from multiple threads?

If you look around for information you’ll find a lot of partial or incorrect info.  A great example was forwarded to me by Gray yesterday (he runs the ormlite project).  It was on stackexchange…

http://stackoverflow.com/questions/2493331/what-is-best-practice-with-sqlite-and-android/2493839

Read More

This is a great post on Android SQLite, and definitely worth taking the time to read. I first found it a year ago on a different blog, the post seems to move around once in a while, so grab an offline copy for safe-keeping.