Android Simultaneous Db Operations -- "database Is Locked"
I'm writing an application with an 'online mode', that is, data is downloaded, parsed and inserted into a SQLite database as needed. All this is performed by a service. The app con
Solution 1:
If your activity is only going to read and not write to database like my case, this is what i did as a workaround:
- create a service ( i.e DatabaseService 0 and use it as a central point to access database (i.e open a database connection) to ensure you only have one dbhelper at a time.
- all activity and service which need to access database have to establish a connection to DatabaseService
- ensure that only your DownloadService's thread is able to write to database and it should use transaction
- after that, you can use getReadable database to read / use the connection to stop the download service , etc.
Just make sure that you only use 1 dbhelper.
Post a Comment for "Android Simultaneous Db Operations -- "database Is Locked""