Search code examples
androidandroid-sqliteandroid-contentproviderandroid-contentresolverandroid-multiple-users

Android: access SQLite database via Content Provider with multiple users in same application


My requirement is to create a sqlitedb which can be shared with any user who logs into the application. Looks like ContentProvider can be used only to share the db with other applications. Is there any way we can create the sqlitedb in /data/data/ folder and access it whenever any user is logged in? I can't run the app with the system user, as it is not requirement.

As the foreground user db creates /data/user/ folder, other users can't access this. Only system user was able to access the db created in /data/data/com.xxx.xxx/databases/.

Any way to resolve this issue?


Solution

  • I've solved this by contentProvider like this. I guess, the picture explains everything.

    enter image description here