androiddatabasesqliteandroid-contentprovidersynchronize

Database handling with 2 processes


I have a an application that has 2 parts.

Each of these run as different processes. The problem is that both of them share a database. And I frequently get database locked error, both when the service tries to write something and the UI is reading data. Also vice versa. How do go about this?

How do I get the two processes share the database. Any cues would be greatly appreciated.


Solution

  • Using a content provider is one option. Another is to take a look at Berkeley DB. The BDB SQL API is SQLite compatible and the BDB lock manager allows multiple threads and/or processes to read/write to the database concurrently.