How do I solve this?
Thanks,
Chris
Some thoughts:
- Any chance multiple threads are trying to consume it when it starts up?
- Does anyone have an open database connection to the database?
- Have you turned on logging to see if you can see when connections are started, DAOs created, etc?
gray
> I don't think its a threading issue. As for having an open connection,
> probably. Should I close the connectionSource, and/or database when I
> do the copy in onUpgrade?
I'm not sure. SQLiteOpenHelper takes in the database name and context and could very easily open a FD to the database or something. Certainly if something has called getReadOnlyConnection() or getReadWriteConnection() on the AndroidConnectionSource then a connection is opened to the database. close() is pretty much a noop unfortunately so that won't help.
Anyone else rebuilding or copying in a new database during application upgrade?
gray
I'd implement checking and copy in a custom Application instance to
make sure it all works out. Since you're copying the database, I
assume there's no personal/local data in there (because it would get
blown away)? I would copy the database from assets each time the app
starts. Write a custom Application instance and do that in onCreate,
before you call the database to do anything.
-Kevin
The prefs idea is interesting. I think thats a good way to handle it.
Get the prefs db name, check if the file exists on the local drive,
and if it doesn't, copy it. Just do it outside of the normal
onCreate/onUpgrade loop.
However, when an app is first installed, the "database" directory
doesn't exist. It may have weird permissions on it. Be careful if
creating manually.
-Kevin
Thanks again,
Chris