ZelluX
ZelluX

Reputation: 72655

Android system service cannot access user data

I'm writing an Android system service under platform/frameworks/base, it is launched by SystemServer and runs as a system service like Activity Manager and Content Manager. The service can access and modify files created by user system successfully, for example, /data/data/com.android.providers.settings/databases/settings.db.

However the service is not able to access data file owned by user applications. For example, /data/data/com.android.providers.contacts/databases/contacts2.db is owned by the user app_7, when trying to change the file, it throws a FileNotFoundException. I'm wondering why a system service cannot modify user data, or is it possible to do so?

Many thanks.

Upvotes: 0

Views: 921

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006914

Presumably, the system service runs as a non-superuser account. This is generally a good thing from a security standpoint.

If you want to access contacts, you can try to do so like any other SDK application, via the ContactsContract content provider.

Upvotes: 1

Related Questions