8

Is there any difference between these two methods? Both return an opened SQLiteDatabase. Both can create a database if one doesn't exist. SQLiteOpenHelper also has getWriteableDatabase when read/write is needed...

Which method should I use and where? Based on sample code I've seen, I'm using SQLiteOpenHelper to create my database in the first place, but then calling SQLiteDatabase.openDatabase when I need to use the database.

GendoIkari
  • 11,734
  • 6
  • 62
  • 104

1 Answers1

3

The openDatabase() is more flexible allowing you to specify locale etc. but for most circumstances where you don't need to explicitly supply those details the Android documentation says to use getReadableDatabase() and getWriteableDatabase().

Gyan aka Gary Buyn
  • 12,242
  • 2
  • 23
  • 26
  • 2
    Also, note that `getReadableDatabase()` will most likely just return `getWriteableDatabase()`. See [this](http://www.netmite.com/android/mydroid/cupcake/frameworks/base/core/java/android/database/sqlite/SQLiteOpenHelper.java). – dmon May 31 '11 at 21:01