1

Everyone,I was looking at android source.But I could not find something valuable for me.Actually,I want to know whether ContentProvider is worked like AIDL.You know ,AIDL can achieve the communication between two independence application.

So, I just want to see how does the ContentProvider work internally.

JMax
  • 26,109
  • 12
  • 69
  • 88
MichaelYe
  • 386
  • 4
  • 15
  • This might help http://stackoverflow.com/a/8591438/444324 – Lior Iluz Oct 29 '12 at 06:57
  • oh,Thank you for your reply..yeah,it said the ContentProvider is based on the AIDL,it's useful for me! If the answer can explain more about how does the ContentProvidor work internally,in source code,will be much better. Anyway,thanks very much! – MichaelYe Oct 29 '12 at 08:43
  • from what I understand, exactly the opposite. – Lior Iluz Oct 29 '12 at 09:19

2 Answers2

1

From ContentProvider Source code

Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications. For example, the contacts data is used by multiple applications and must be stored in a content provider. If you don't need to share data amongst multiple applications you can use a database directly via android.database.sqlite.SQLiteDatabase.

According to this and to the information in the link I sent you, ContentProvider isn't using AIDL... It is using the ContentResolver interface.

Lior Iluz
  • 26,213
  • 16
  • 65
  • 114
  • hi,Liorry.Thanks for your reply..I am agree with you that the ContentProvider is using the ContentResolver interface.But How dose it achieve that expose the data to other applications ? Accroding to this [link](stackoverflow.com/a/8591438/444324) I think it's AIDL.But I am not quite sure. What do you think of ? – MichaelYe Oct 29 '12 at 09:28
  • @user1727934 unlike AIDL, contentProvider doesn't allow communication between applications. It only allows data sharing. I think it's based on the same way you can share your sharedPreferences (Activity.MODE_WORLD_READABLE/WRITABLE). It's just a flag that tells the system you allow public access to this file/SQL db. Same as Android itself reveals the contacts, bookmarks, etc... they use a contentProvider. – Lior Iluz Oct 29 '12 at 11:21
1

Content Providers use IPC Binders internally. "In fact, Intents and ContentProvider are just a higher-level abstraction of Binder"

stack_ved
  • 721
  • 3
  • 11