Saturday, 24 August 2013

Is it safe to use multiple SQLiteDatabases and SQLiteOpenHelpers in one Android project?

Is it safe to use multiple SQLiteDatabases and SQLiteOpenHelpers in one
Android project?

I have my android project (projectA) which I have to join with other 3rd
party project (projectB) with minimal changes to both. I figured the nice
way to do it would be to convert projectA to a library and make projectB
use that lib.
The problem is the both projects use SQLite databases. They have their own
SQLiteOpenHelpers and stuff, in short they both are written the normal way
an android app that uses DB is written (their DATABASE_NAMES are different
of course).
I wonder if there may be a potential of some conflict in this scenario? I
don't know, some database deadlocks, hard to debug crashes etc? I'm a
little worried because I saw this exception yesterday:
java.lang.IllegalStateException: attempt to re-open an already-closed
object: SQLiteDatabase:
/data/data/[com.pacekage.url.of.projectB]/databases/[projectAdatabaseName]
This may be related just to some bug in projectA, but I want to be sure
that it is not caused by some confilct between the databases and that this
kind of scenario I'm describing is acceptable. What are the potential
pitfalls, things to watch for, best practices when joining two android
projects with separate databases?

No comments:

Post a Comment