My app syncs contacts with a custom server, with a lot of custom properties. Because of that, it has a built-in contact editor for its own contacts, and I don't want the native Contacts app to allow editing of these contacts. I thought that setting android:supportsUploading="false" in the sync-adapter xml would do what I want, but it doesn't. Here's the full XML file:
<sync-adapter
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.myapp.ContactSync"
android:contentAuthority="com.android.contacts"
android:userVisible="false"
android:supportsUploading="false"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="false"
/>
I've tried this on a Google Pixel 6 (Android 12), and an older tablet running Android 5.0, and the results are the same - if I open one of my "custom" contacts in the native Contacts app, it allows the user to edit it. But it's using the default set of contact fields (like Phonetic First, Middle, and Last names, etc.), which are not supported on my server. So, if the user actually enters any data into those fields, my sync adapter sees the contact as being changed, and tries to sync it back to the server.
As I said, my goal is to only allow editing of these contacts inside my app. Can that be done?
EDIT:
Just to clarify, I've already eliminated the possibility of this being a some kind of a bug with Contact Aggregation. I tested this on multiple devices, where there were no other contacts loaded, only the ones added by my app. I also tried setting AGGREGATION_MODE_DISABLED for every contact,e edited, but that didn't solve the problem.
Yes, that is the correct way of doing that.
Few notes: