1

While Implementing SQLite data base in android In my Application I have different 5 database tables. I found two ways to implement this

1) create different database for each table and respective SQLiteOpenHelper implementation.

2) Create 1 database and only 1 SQLiteOpenHelper implementation in that, create all the required tables

I have below queries regarding the above methods.

a) The SQLiteDatabase db = this.getReadableDatabase(); will get database in RAM to operate on It In case 1) we have a separate database for each table so it will load respective database in memory ? In case 2) We have single database having all the tables so the all the tables will come in RAM ?

b)In case 2 What if one feature updating in one table and other in 2nd table and 1st feature completed its task and calls close on database then what will happen to the 2nd feature which is still in process ? will there be any exception ?

2
  • Managing several databases will require handling all of them (opening, closing, ...). The amount of database data in RAM will be the same. But you would have more database objects Commented Aug 6, 2014 at 8:16
  • 1
    @1) hahahaha what for? how will you use join statment? ... @a) who cares @b) use ContentProvider, there will be only one instance of db class inside CP there will be no sens to call close on db instance at all Commented Aug 6, 2014 at 8:19

1 Answer 1

4

This is mainly a design question.

If your tables make a consistent whole altogether, they should be stored in a same database. If they are independant, completely unrelated, with no common purpose or use case, these are as many databases.

For example: the tables Users, Accounts, AccessRights should be in a same database as the Users do have Accounts that are granted AccessRights.

Keeping data consistent across multiple tables (the model) is actually the purpose of a database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.