Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLiteOpenHelper multiple in-memory databases

android.database.sqlite.SQLiteOpenHelper provides the ability to use an in-memory database if the name argument to its constructor is null:

String: of the database file, or null for an in-memory database

If SQLiteOpenHelper is instantiated multiple times with a null name argument, do they access the same in-memory database or is a separate in-memory database created each time?

like image 288
arcyqwerty Avatar asked May 04 '16 18:05

arcyqwerty


1 Answers

From SQLite official documentation In-Memory Databases

Opening two database connections each with the filename ":memory:" will create two independent in-memory databases.

In Android, pass null instead of ":memory:"

So, If you instantiate SQLiteOpenHelper multiple times with a null name argument then it create separate in-memory database created each time

like image 76
USKMobility Avatar answered Oct 06 '22 01:10

USKMobility