1

I have been researching everything I can on Content Providers, but I cannot grasp the concept of how other apps installed on the phone can have access to the Content I am Providing. How can other apps possibly know what my CONTENT_URIs are???

I am making a Contacts app. How can other apps get the contact data I have stored, it seems impossible another app would know what I have set for the CONTENT_URI. Doesn't this defeat the whole purpose of Content Providing if other apps need to know basically what the secret key is that only I would know?

I want other apps to see my Contact app data instead of ignoring mine and only looking to the stock Contacts app for data.

Why would Android create the ContactsContract provider if that is going to lead to developers using that to obtain contact data, therefore by default making all other 3rd party contacts apps obsolete because other developers would be writing code essentially to only grab Contact data from the stock Android Contact app?

Android doesn't seem to provide anyway for me to provide by data to other apps using the ContactsContracts provider. Yet of coarse Android has made it very clear, easy, and encourages developers needing contact data to use ContactsContract.

Is this a blatant power grab? The whole intention of my contacts app is to make my Contact data more secure so that Google isn't able to collect it if they so choose, or anyone else for that matter.

Please can someone advise? This cannot possibly be correct, I am hoping I have misunderstood here. Again just FYI, I have found nothing anywhere on the Android Developer page that refers to the issue I am having.

  • What would be the benefit of using your contacts ContentProvider over the stock contacts storage ContentProvider? Why would I want that as a user or as an app developer? – Marten May 04 '16 at 10:22
  • I would certainly rather use the ContactsContract provider as opposed to creating my own, but unfortunately that is where the problem lies. I don't seem to be able to provide contact data to other apps identically to how the stock app does it. I am building a 100% replacement Contacts app where your contact data is more secure. Plus I just think the stock app is ugly and clunky and I can do better. I WANT my providers to provide data exactly how the stock app does. Why can't android release the documentation on how I can do that? How is that fair? – JamisonMan111 May 04 '16 at 21:19
  • Why don't you just write a SyncAdapter and write your own data into the default ContactsProvider? You also can write your own Contacts app that uses the stock ContactsProvider. Btw, the stock Contacts Application and the stock Contacts Storage are 2 separate apps. The stock Contacts Application is just a "front-end" to the stock Contacts Provider. You could just write your own "front-end" (like others before you did). – Marten May 05 '16 at 20:51

1 Answers1

2

This is definitely not a power grab. The contacts are embedded into the operating system because users require their phone to store phone numbers along with a name and other information to associate with that phone number. Google is not doing anything different than the flip phones did back in the day, except for giving users the option to sync their contacts to the cloud. However, that is not required. A user can add a contact to their phone and simply have it pertain to the phone.

The ContactsContract allows apps to access the contacts stored on the device, which is only possible after the user gives permission to the app to access their contacts. There are apps that use this functionality to act as contacts managers (apps that display the user's contacts in a different layout). Some apps provide the user with the service of backing up their contacts online in case the user did not want to use Google (e.g. FullContact). However, the majority of apps typically read contacts for other reasons, such as helping the user find friends/acquaintances/coworkers/etc who have an account in their app.

To address the issue of how other developers realize an app's CONTENT_URI, they do so by reading the developers' documentation. If you are the developer providing content, then it is your responsibility to publish the necessary documentation in order to let other developers understand how to work with your app.

AgileNinja
  • 914
  • 1
  • 7
  • 20
  • All contact data needs only to be stored in a database. Then the Content Providers make it easily available. That is the Android model that I learned from reading the Android Developer website. I understand exactly how the ContactsContract provider works. I need to know how to use it in my code to PROVIDE data, not retrieve it. Google doesn't seem to allow this? Why would that be? Thank you for the info about publishing my providers for other developers. I was afraid that was my only option left and may have to choose that route – JamisonMan111 May 04 '16 at 21:21
  • @JamisonMan111 You can provide data by writing it into the stock Contacts Provider. That's how all other apps do it. No offense, but I don't think that you've understood Android ContentProviders OR I still didn't understand what you're trying to achieve that can't be done using the stock ContactsProvider. – Marten May 05 '16 at 20:56
  • No offense taken I appreciate your help. I thought I understood Content Providers because I use them, although not frequently. I suppose I should try writing my data into ContactsContract, I didn't realize that was an option. One of my main concerns was that I do not want my Contact information tethered to the google account on the phone. Using a Nexus 6, Android 5.1.1, there is no longer an option to keep contacts "Local". Any contact I enter is now part of the google account on the phone and I want my information private. – JamisonMan111 May 08 '16 at 23:12