Using of contact information & datamodel presentation in AndroidAlexey Potapov
• Introduction to Contacts Provider  Structure• Contacts Provider Access and Data  Consistency• Determination changes
Contacts Provider Structure• ContactsContract.Contacts• ContactsContract.RawContacts• ContactsContract.Data
ContactsContract.RawContacts• Sources of raw contacts data  o Google  o Facebook  o etc.• Important raw contact columns  o...
ContactsContract.Data• Important raw contact columns• Generic column names  o Data1 , … , Data16• Type-specific column nam...
ContactsContract.Contacts• Neither applications nor  sync adapters are allowed  to add contacts• Contact is representation...
Contacts Provider Metadata•   ContactsContract.RawContacts.DIRTY•   ContactsContract.RawContacts.VERSION•   ContactsContra...
Contacts Provider Access and Data           Consistency• Contacts Aggregation• Query contacts and data• Batch modification
Contacts Aggregation                               ID=1              Join      ID=3ID=1   ID=1                            ...
Query contacts and data• Lookup Key vs. Contact ID  Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,  String.va...
Batch modification• Yield points  o to prevent blocking the system• Modification back references  o to use result of a pre...
Determination changes• ContentObserver  o onChange(boolean selfChange)  o onChange(boolean selfChange, Uri uri)   API 16• ...
SELECT * FROM raw_contacts    WHERE        id||‘.’||contact_id||’.’            ||version    NOT IN (?)SELECT * FROM data  ...
Questions ?      © Alexey Potapov
Upcoming SlideShare
Loading in …5
×

Using of contact information & data model presentation in android - Алексей Потапов

840 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
840
On SlideShare
0
From Embeds
0
Number of Embeds
38
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using of contact information & data model presentation in android - Алексей Потапов

  1. 1. Using of contact information & datamodel presentation in AndroidAlexey Potapov
  2. 2. • Introduction to Contacts Provider Structure• Contacts Provider Access and Data Consistency• Determination changes
  3. 3. Contacts Provider Structure• ContactsContract.Contacts• ContactsContract.RawContacts• ContactsContract.Data
  4. 4. ContactsContract.RawContacts• Sources of raw contacts data o Google o Facebook o etc.• Important raw contact columns o ACCOUNT_NAME o ACCOUNT_TYPE
  5. 5. ContactsContract.Data• Important raw contact columns• Generic column names o Data1 , … , Data16• Type-specific column names o CommonDataKinds.Photo o CommonDataKinds.Email o etc.
  6. 6. ContactsContract.Contacts• Neither applications nor sync adapters are allowed to add contacts• Contact is representation of RawContacts aggregation
  7. 7. Contacts Provider Metadata• ContactsContract.RawContacts.DIRTY• ContactsContract.RawContacts.VERSION• ContactsContract.Data.DATA_VERSION• ContactsContract.RawContacts.SOURCE_ID• ContactsContract.RawContacts.DELETED
  8. 8. Contacts Provider Access and Data Consistency• Contacts Aggregation• Query contacts and data• Batch modification
  9. 9. Contacts Aggregation ID=1 Join ID=3ID=1 ID=1 ID=2ID=2 ID=2 ID=3 ID=1 Separate ID=4 ID=2
  10. 10. Query contacts and data• Lookup Key vs. Contact ID Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(mId)); ContactsContract.Contacts.getLookupUri(mId, mLookupKey);• Query entities API 11 Uri.withAppendedPath(mContactUri, ContactsContract.Contacts.Entity.CONTENT_DIRECTORY);
  11. 11. Batch modification• Yield points o to prevent blocking the system• Modification back references o to use result of a previous operation• Optimistic concurrency control o modification of database without having to lock the underlying repository
  12. 12. Determination changes• ContentObserver o onChange(boolean selfChange) o onChange(boolean selfChange, Uri uri) API 16• Check db modifications by query o What we have? o What we want?
  13. 13. SELECT * FROM raw_contacts WHERE id||‘.’||contact_id||’.’ ||version NOT IN (?)SELECT * FROM data WHERE id||‘.’||data_version NOT IN (?)? starred, etc.
  14. 14. Questions ? © Alexey Potapov

×