কন্টাক্টস প্রোভাইডার হল একটি শক্তিশালী এবং নমনীয় অ্যান্ড্রয়েড কম্পোনেন্ট যা ডিভাইসের কেন্দ্রীয় ভান্ডারের মানুষের তথ্য পরিচালনা করে। কন্টাক্টস প্রোভাইডার হল ডিভাইসের কন্টাক্টস অ্যাপ্লিকেশনে আপনি যে ডেটা দেখতে পান তার উৎস, এবং আপনি আপনার নিজস্ব অ্যাপ্লিকেশনে এর ডেটা অ্যাক্সেস করতে পারেন এবং ডিভাইস এবং অনলাইন পরিষেবাগুলির মধ্যে ডেটা স্থানান্তর করতে পারেন। প্রোভাইডার বিস্তৃত ডেটা উৎস ধারণ করে এবং প্রতিটি ব্যক্তির জন্য যতটা সম্ভব ডেটা পরিচালনা করার চেষ্টা করে, যার ফলে এর সংগঠন জটিল হয়ে ওঠে। এই কারণে, প্রোভাইডার এর API তে চুক্তির ক্লাস এবং ইন্টারফেসের একটি বিস্তৃত সেট রয়েছে যা ডেটা পুনরুদ্ধার এবং পরিবর্তন উভয়কেই সহজতর করে।
এই নির্দেশিকাটি নিম্নলিখিত বিষয়গুলি বর্ণনা করে:
- মৌলিক প্রদানকারী কাঠামো।
 - সরবরাহকারীর কাছ থেকে কীভাবে ডেটা পুনরুদ্ধার করবেন।
 - প্রোভাইডারে ডেটা কীভাবে পরিবর্তন করবেন।
 - আপনার সার্ভার থেকে পরিচিতি সরবরাহকারীর সাথে ডেটা সিঙ্ক্রোনাইজ করার জন্য কীভাবে একটি সিঙ্ক অ্যাডাপ্টার লিখবেন।
 
এই নির্দেশিকাটি ধরে নিয়েছে যে আপনি অ্যান্ড্রয়েড কন্টেন্ট প্রোভাইডারদের মূল বিষয়গুলি জানেন। অ্যান্ড্রয়েড কন্টেন্ট প্রোভাইডারদের সম্পর্কে আরও জানতে, কন্টেন্ট প্রোভাইডার বেসিক গাইডটি পড়ুন।
যোগাযোগ প্রদানকারী সংস্থা
কন্টাক্টস প্রোভাইডার হল একটি অ্যান্ড্রয়েড কন্টেন্ট প্রোভাইডার উপাদান। এটি একজন ব্যক্তির সম্পর্কে তিন ধরণের ডেটা বজায় রাখে, যার প্রতিটি প্রদানকারীর দ্বারা প্রদত্ত টেবিলের সাথে মিলে যায়, যেমন চিত্র 1 এ দেখানো হয়েছে:

চিত্র ১. পরিচিতি সরবরাহকারীর টেবিল গঠন।
তিনটি টেবিল সাধারণত তাদের চুক্তি ক্লাসের নাম দ্বারা উল্লেখ করা হয়। ক্লাসগুলি টেবিল দ্বারা ব্যবহৃত কন্টেন্ট URI, কলামের নাম এবং কলামের মানের জন্য ধ্রুবক নির্ধারণ করে:
-  
ContactsContract.Contactsটেবিল - অপরিশোধিত পরিচিতি সারির সমষ্টির উপর ভিত্তি করে বিভিন্ন ব্যক্তিকে প্রতিনিধিত্বকারী সারি।
 -  
ContactsContract.RawContactsটেবিল - ব্যবহারকারীর অ্যাকাউন্ট এবং প্রকারের জন্য নির্দিষ্ট ব্যক্তির ডেটার সারাংশ ধারণকারী সারি।
 -  
ContactsContract.Dataটেবিল - যেসব সারিগুলিতে অপরিচিত পরিচিতির বিবরণ থাকে, যেমন ইমেল ঠিকানা বা ফোন নম্বর।
 
 ContactsContract এ চুক্তি শ্রেণী দ্বারা উপস্থাপিত অন্যান্য টেবিলগুলি হল সহায়ক টেবিল যা Contacts Provider তার ক্রিয়াকলাপ পরিচালনা করতে বা ডিভাইসের পরিচিতি বা টেলিফোনি অ্যাপ্লিকেশনগুলিতে নির্দিষ্ট ফাংশনগুলিকে সমর্থন করতে ব্যবহার করে।
অ-সংযুক্ত পরিচিতি
একটি কাঁচা পরিচিতি একজন ব্যক্তির একক অ্যাকাউন্টের ধরণ এবং অ্যাকাউন্টের নাম থেকে আসা ডেটা উপস্থাপন করে। যেহেতু পরিচিতি সরবরাহকারী একজন ব্যক্তির জন্য একাধিক অনলাইন পরিষেবাকে ডেটার উৎস হিসেবে অনুমোদন করে, তাই পরিচিতি সরবরাহকারী একই ব্যক্তির জন্য একাধিক কাঁচা পরিচিতি অনুমোদন করে। একাধিক কাঁচা পরিচিতি একজন ব্যবহারকারীকে একই অ্যাকাউন্টের ধরণ থেকে একাধিক অ্যাকাউন্ট থেকে একজন ব্যক্তির ডেটা একত্রিত করার অনুমতি দেয়।
 একটি কাঁচা পরিচিতির বেশিরভাগ ডেটা ContactsContract.RawContacts টেবিলে সংরক্ষণ করা হয় না। পরিবর্তে, এটি ContactsContract.Data টেবিলে এক বা একাধিক সারিতে সংরক্ষণ করা হয়। প্রতিটি ডেটা সারিতে একটি Data.RAW_CONTACT_ID কলাম থাকে যাতে এর মূল ContactsContract.RawContacts সারির RawContacts._ID মান থাকে।
গুরুত্বপূর্ণ কাঁচা যোগাযোগ কলাম
 ContactsContract.RawContacts টেবিলের গুরুত্বপূর্ণ কলামগুলি টেবিল ১-এ তালিকাভুক্ত করা হয়েছে। টেবিলের পরে থাকা নোটগুলি অনুগ্রহ করে পড়ুন:
সারণী ১. গুরুত্বপূর্ণ কাঁচা যোগাযোগ কলাম।
| কলামের নাম | ব্যবহার করুন | মন্তব্য | 
|---|---|---|
 ACCOUNT_NAME |  এই অপরিশোধিত পরিচিতির উৎস হিসেবে ব্যবহৃত অ্যাকাউন্টের নাম। উদাহরণস্বরূপ, একটি Google অ্যাকাউন্টের অ্যাকাউন্টের নাম হল ডিভাইসের মালিকের Gmail ঠিকানাগুলির মধ্যে একটি। আরও তথ্যের জন্য ACCOUNT_TYPE এর পরবর্তী এন্ট্রিটি দেখুন। | এই নামের ফর্ম্যাটটি এর অ্যাকাউন্টের ধরণের সাথে সুনির্দিষ্ট। এটি অবশ্যই কোনও ইমেল ঠিকানা নয়। | 
 ACCOUNT_TYPE |  এই অ-সংযোগের উৎস হল অ্যাকাউন্টের ধরণ। উদাহরণস্বরূপ, একটি Google অ্যাকাউন্টের অ্যাকাউন্টের ধরণ হল com.google । আপনার মালিকানাধীন বা নিয়ন্ত্রণাধীন ডোমেনের জন্য সর্বদা একটি ডোমেন শনাক্তকারী দিয়ে আপনার অ্যাকাউন্টের ধরণকে যোগ্যতা অর্জন করুন। এটি নিশ্চিত করবে যে আপনার অ্যাকাউন্টের ধরণটি অনন্য। | যে অ্যাকাউন্টের ধরণে পরিচিতি সম্পর্কিত তথ্য থাকে, তাতে সাধারণত একটি সংশ্লিষ্ট সিঙ্ক অ্যাডাপ্টার থাকে যা পরিচিতি সরবরাহকারীর সাথে সিঙ্ক্রোনাইজ হয়। | 
 DELETED | একটি অপ্রচলিত পরিচিতির জন্য "মুছে ফেলা" পতাকা। | এই ফ্ল্যাগটি কন্টাক্টস প্রোভাইডারকে অভ্যন্তরীণভাবে সারিটি বজায় রাখার অনুমতি দেয় যতক্ষণ না সিঙ্ক অ্যাডাপ্টারগুলি তাদের সার্ভার থেকে সারিটি মুছে ফেলতে সক্ষম হয় এবং অবশেষে সংগ্রহস্থল থেকে সারিটি মুছে ফেলতে সক্ষম হয়। | 
মন্তব্য
 ContactsContract.RawContacts টেবিল সম্পর্কে গুরুত্বপূর্ণ নোটগুলি নিম্নরূপ:
-  একটি কাঁচা পরিচিতির নাম 
ContactsContract.RawContactsএর সারিতে সংরক্ষণ করা হয় না। পরিবর্তে, এটিContactsContract.Dataটেবিলে, একটিContactsContract.CommonDataKinds.StructuredNameসারিতে সংরক্ষণ করা হয়। একটি কাঁচা পরিচিতিরContactsContract.Dataটেবিলে এই ধরণের কেবল একটি সারি থাকে। -  সতর্কতা: আপনার নিজের অ্যাকাউন্টের ডেটা একটি কাঁচা যোগাযোগ সারিতে ব্যবহার করতে, প্রথমে এটি 
AccountManagerএ নিবন্ধিত হতে হবে। এটি করার জন্য, ব্যবহারকারীদের অ্যাকাউন্টের তালিকায় অ্যাকাউন্টের ধরণ এবং তাদের অ্যাকাউন্টের নাম যোগ করতে বলুন। যদি আপনি এটি না করেন, তাহলে যোগাযোগ প্রদানকারী স্বয়ংক্রিয়ভাবে আপনার কাঁচা যোগাযোগ সারিতে মুছে ফেলবে।উদাহরণস্বরূপ, যদি আপনি চান যে আপনার অ্যাপটি
com.example.dataserviceডোমেনের মাধ্যমে আপনার ওয়েব-ভিত্তিক পরিষেবার জন্য পরিচিতি ডেটা বজায় রাখুক, এবং আপনার পরিষেবার জন্য ব্যবহারকারীর অ্যাকাউন্ট হলbecky.sharp@dataservice.example.com, তাহলে আপনার অ্যাপটি কাঁচা যোগাযোগের সারি যোগ করার আগে ব্যবহারকারীকে প্রথমে অ্যাকাউন্ট "টাইপ" (com.example.dataservice) এবং অ্যাকাউন্ট "নাম" (becky.smart@dataservice.example.com) যোগ করতে হবে। আপনি ডকুমেন্টেশনে ব্যবহারকারীকে এই প্রয়োজনীয়তা ব্যাখ্যা করতে পারেন, অথবা আপনি ব্যবহারকারীকে টাইপ এবং নাম, অথবা উভয়ই যোগ করতে অনুরোধ করতে পারেন। অ্যাকাউন্টের ধরণ এবং অ্যাকাউন্টের নাম পরবর্তী বিভাগে আরও বিশদে বর্ণনা করা হয়েছে। 
কাঁচা যোগাযোগের তথ্যের উৎস
কাঁচা পরিচিতিগুলি কীভাবে কাজ করে তা বোঝার জন্য, "এমিলি ডিকিনসন" ব্যবহারকারীর কথা বিবেচনা করুন যার ডিভাইসে নিম্নলিখিত তিনটি ব্যবহারকারী অ্যাকাউন্ট সংজ্ঞায়িত রয়েছে:
-  
emily.dickinson@gmail.com -  
emilyd@gmail.com - টুইটার অ্যাকাউন্ট "belle_of_amherst"
 
এই ব্যবহারকারী অ্যাকাউন্ট সেটিংসে এই তিনটি অ্যাকাউন্টের জন্যই সিঙ্ক কন্টাক্টস সক্ষম করেছেন।
 ধরুন এমিলি ডিকিনসন একটি ব্রাউজার উইন্ডো খুলেন, emily.dickinson@gmail.com হিসেবে Gmail-এ লগ ইন করেন, Contacts খুলেন এবং "Thomas Higginson" যোগ করেন। পরবর্তীতে, তিনি emilyd@gmail.com হিসেবে Gmail-এ লগ ইন করেন এবং "Thomas Higginson"-এ একটি ইমেল পাঠান, যা স্বয়ংক্রিয়ভাবে তাকে একজন পরিচিতি হিসেবে যুক্ত করে। তিনি টুইটারে "colonel_tom" (Thomas Higginson-এর টুইটার আইডি) অনুসরণ করেন।
এই কাজের ফলে পরিচিতি সরবরাহকারী তিনটি কাঁচা পরিচিতি তৈরি করে:
-  
emily.dickinson@gmail.comএর সাথে সম্পর্কিত "Thomas Higginson" এর জন্য একটি অপ্রচলিত পরিচিতি। ব্যবহারকারীর অ্যাকাউন্টের ধরণ হল Google। -  "থমাস হিগিনসন" এর জন্য দ্বিতীয় অপরিশোধিত পরিচিতি 
emilyd@gmail.comএর সাথে সম্পর্কিত। ব্যবহারকারীর অ্যাকাউন্টের ধরণটিও গুগল। দ্বিতীয় অপরিশোধিত পরিচিতি রয়েছে যদিও নামটি পূর্ববর্তী নামের সাথে অভিন্ন, কারণ ব্যক্তিটিকে একটি ভিন্ন ব্যবহারকারী অ্যাকাউন্টের জন্য যুক্ত করা হয়েছিল। - "belle_of_amherst" এর সাথে সম্পর্কিত "Thomas Higginson" এর তৃতীয় অপরিশোধিত পরিচিতি। ব্যবহারকারীর অ্যাকাউন্টের ধরণ হল টুইটার।
 
উপাত্ত
 যেমনটি আগে উল্লেখ করা হয়েছে, একটি কাঁচা পরিচিতির ডেটা একটি ContactsContract.Data সারিতে সংরক্ষণ করা হয় যা কাঁচা পরিচিতির _ID মানের সাথে লিঙ্ক করা থাকে। এটি একটি একক কাঁচা পরিচিতিতে একই ধরণের ডেটার একাধিক উদাহরণ যেমন ইমেল ঠিকানা বা ফোন নম্বর থাকতে দেয়। উদাহরণস্বরূপ, যদি emilyd@gmail.com এর জন্য "Thomas Higginson" (Google অ্যাকাউন্ট emilyd@gmail.com এর সাথে সম্পর্কিত Thomas Higginson এর কাঁচা যোগাযোগের সারি) এর একটি হোম ইমেল ঠিকানা thigg@gmail.com এবং একটি কাজের ইমেল ঠিকানা thomas.higginson@gmail.com থাকে, তাহলে Contacts Provider দুটি ইমেল ঠিকানার সারি সংরক্ষণ করে এবং উভয়কেই কাঁচা পরিচিতির সাথে লিঙ্ক করে।
 লক্ষ্য করুন যে এই একক টেবিলে বিভিন্ন ধরণের ডেটা সংরক্ষণ করা হয়েছে। প্রদর্শন নাম, ফোন নম্বর, ইমেল, ডাক ঠিকানা, ছবি এবং ওয়েবসাইটের বিস্তারিত সারিগুলি ContactsContract.Data টেবিলে পাওয়া যায়। এটি পরিচালনা করতে সাহায্য করার জন্য, ContactsContract.Data টেবিলে বর্ণনামূলক নাম সহ কিছু কলাম রয়েছে এবং অন্যগুলি জেনেরিক নাম সহ। বর্ণনামূলক-নাম কলামের বিষয়বস্তু সারিতে থাকা ডেটার ধরণ নির্বিশেষে একই অর্থ বহন করে, অন্যদিকে জেনেরিক-নাম কলামের বিষয়বস্তু ডেটার ধরণের উপর নির্ভর করে বিভিন্ন অর্থ বহন করে।
বর্ণনামূলক কলামের নাম
বর্ণনামূলক কলামের নামের কিছু উদাহরণ হল:
-  
RAW_CONTACT_ID -  এই ডেটার জন্য কাঁচা পরিচিতির 
_IDকলামের মান। -  
MIMETYPE -  এই সারিতে সংরক্ষিত ডেটার ধরণ, একটি কাস্টম MIME টাইপ হিসেবে প্রকাশ করা হয়েছে। Contacts Provider 
ContactsContract.CommonDataKindsএর উপশ্রেণীতে সংজ্ঞায়িত MIME টাইপগুলি ব্যবহার করে। এই MIME টাইপগুলি ওপেন সোর্স, এবং Contacts Provider এর সাথে কাজ করে এমন যেকোনো অ্যাপ্লিকেশন বা সিঙ্ক অ্যাডাপ্টার দ্বারা ব্যবহার করা যেতে পারে। -  
IS_PRIMARY -  যদি এই ধরণের ডেটা সারি কোনও কাঁচা পরিচিতির জন্য একাধিকবার দেখা দিতে পারে, তাহলে 
IS_PRIMARYকলামটি সেই ডেটা সারিটিকে চিহ্নিত করে যেখানে সেই ধরণের প্রাথমিক ডেটা থাকে। উদাহরণস্বরূপ, যদি ব্যবহারকারী কোনও পরিচিতির জন্য একটি ফোন নম্বর দীর্ঘক্ষণ টিপে "সেট ডিফল্ট" নির্বাচন করেন, তাহলেContactsContract.Dataসারিটিতে সেই নম্বরটি থাকাIS_PRIMARYকলামটি একটি অ-শূন্য মান হিসাবে সেট করা থাকে। 
সাধারণ কলামের নাম
 DATA1 থেকে DATA15 নামে ১৫টি জেনেরিক কলাম সাধারণত পাওয়া যায় এবং SYNC1 থেকে SYNC4 পর্যন্ত আরও চারটি জেনেরিক কলাম রয়েছে যা শুধুমাত্র সিঙ্ক অ্যাডাপ্টার দ্বারা ব্যবহার করা উচিত। জেনেরিক কলামের নামের ধ্রুবকগুলি সর্বদা কাজ করে, সারিতে যে ধরণের ডেটা থাকুক না কেন।
 DATA1 কলামটি সূচীবদ্ধ করা হয়েছে। যোগাযোগ সরবরাহকারী সর্বদা এই কলামটি সেই ডেটার জন্য ব্যবহার করে যা সরবরাহকারী আশা করে যে কোনও প্রশ্নের সবচেয়ে ঘন ঘন লক্ষ্য হবে। উদাহরণস্বরূপ, একটি ইমেল সারিতে, এই কলামে আসল ইমেল ঠিকানা থাকে।
 প্রচলিত পদ্ধতি অনুসারে, DATA15 কলামটি বাইনারি লার্জ অবজেক্ট (BLOB) ডেটা যেমন ছবির থাম্বনেইল সংরক্ষণের জন্য সংরক্ষিত।
টাইপ-নির্দিষ্ট কলামের নাম
 একটি নির্দিষ্ট ধরণের সারির জন্য কলামগুলির সাথে কাজ করার সুবিধার্থে, Contacts Provider টাইপ-নির্দিষ্ট কলাম নামের ধ্রুবকও প্রদান করে, যা ContactsContract.CommonDataKinds এর উপশ্রেণীতে সংজ্ঞায়িত করা হয়। ধ্রুবকগুলি কেবল একই কলামের নামের জন্য একটি ভিন্ন ধ্রুবক নাম দেয়, যা আপনাকে একটি নির্দিষ্ট ধরণের সারিতে ডেটা অ্যাক্সেস করতে সহায়তা করে।
 উদাহরণস্বরূপ, ContactsContract.CommonDataKinds.Email ক্লাসটি ContactsContract.Data সারির জন্য টাইপ-নির্দিষ্ট কলামের নামের ধ্রুবক নির্ধারণ করে যার MIME টাইপ Email.CONTENT_ITEM_TYPE আছে। ক্লাসটিতে ইমেল ঠিকানা কলামের জন্য ধ্রুবক ADDRESS রয়েছে। ADDRESS এর প্রকৃত মান হল "data1", যা কলামের জেনেরিক নামের অনুরূপ।
 সাবধানতা: ContactsContract.Data টেবিলে আপনার নিজস্ব কাস্টম ডেটা এমন কোনও সারি ব্যবহার করে যোগ করবেন না যেখানে সরবরাহকারীর পূর্ব-নির্ধারিত MIME প্রকার রয়েছে। যদি আপনি তা করেন, তাহলে আপনি ডেটা হারাতে পারেন অথবা সরবরাহকারীর ত্রুটি দেখা দিতে পারে। উদাহরণস্বরূপ, আপনার MIME প্রকার Email.CONTENT_ITEM_TYPE সহ এমন একটি সারি যোগ করা উচিত নয় যাতে DATA1 কলামে ইমেল ঠিকানার পরিবর্তে একটি ব্যবহারকারীর নাম থাকে। আপনি যদি সারির জন্য আপনার নিজস্ব কাস্টম MIME প্রকার ব্যবহার করেন, তাহলে আপনি আপনার নিজস্ব টাইপ-নির্দিষ্ট কলামের নাম নির্ধারণ করতে এবং আপনার ইচ্ছামত কলামগুলি ব্যবহার করতে স্বাধীন।
 চিত্র ২ দেখায় কিভাবে বর্ণনামূলক কলাম এবং ডেটা কলামগুলি একটি ContactsContract.Data সারিতে প্রদর্শিত হয়, এবং কীভাবে টাইপ-নির্দিষ্ট কলামের নামগুলি জেনেরিক কলামের নামগুলিকে "ওভারলে" করে 

চিত্র ২। টাইপ-নির্দিষ্ট কলামের নাম এবং জেনেরিক কলামের নাম।
টাইপ-নির্দিষ্ট কলামের নামের ক্লাস
সারণি ২-এ সর্বাধিক ব্যবহৃত টাইপ-নির্দিষ্ট কলামের নামের ক্লাসগুলির তালিকা দেওয়া হয়েছে:
সারণি ২। টাইপ-নির্দিষ্ট কলামের নাম ক্লাস
| ম্যাপিং ক্লাস | তথ্যের ধরণ | মন্তব্য | 
|---|---|---|
 ContactsContract.CommonDataKinds.StructuredName | এই ডেটা সারির সাথে সম্পর্কিত কাঁচা পরিচিতির নামের ডেটা। | একটি কাঁচা পরিচিতিতে এই সারিগুলির মধ্যে কেবল একটি থাকে। | 
 ContactsContract.CommonDataKinds.Photo | এই ডেটা সারির সাথে সম্পর্কিত কাঁচা পরিচিতির মূল ছবি। | একটি কাঁচা পরিচিতিতে এই সারিগুলির মধ্যে কেবল একটি থাকে। | 
 ContactsContract.CommonDataKinds.Email | এই ডেটা সারির সাথে সম্পর্কিত কাঁচা পরিচিতির জন্য একটি ইমেল ঠিকানা। | একটি অ-রক্ষিত পরিচিতির একাধিক ইমেল ঠিকানা থাকতে পারে। | 
 ContactsContract.CommonDataKinds.StructuredPostal | এই ডেটা সারির সাথে সম্পর্কিত কাঁচা যোগাযোগের জন্য একটি ডাক ঠিকানা। | একটি অ-সংশ্লিষ্ট পরিচিতির একাধিক ডাক ঠিকানা থাকতে পারে। | 
 ContactsContract.CommonDataKinds.GroupMembership | একটি শনাক্তকারী যা পরিচিতি সরবরাহকারীর গ্রুপগুলির একটির সাথে কাঁচা পরিচিতিকে লিঙ্ক করে। | গ্রুপগুলি হল অ্যাকাউন্টের ধরণ এবং অ্যাকাউন্টের নামের একটি ঐচ্ছিক বৈশিষ্ট্য। এগুলি সম্পর্কে "যোগাযোগ গ্রুপ" বিভাগে আরও বিস্তারিতভাবে বর্ণনা করা হয়েছে। | 
পরিচিতি
পরিচিতি সরবরাহকারী সকল অ্যাকাউন্টের ধরণ এবং অ্যাকাউন্টের নামের মধ্যে কাঁচা যোগাযোগের সারিগুলিকে একত্রিত করে একটি পরিচিতি তৈরি করে। এটি একজন ব্যবহারকারীর জন্য সংগৃহীত সমস্ত ডেটা প্রদর্শন এবং পরিবর্তন করতে সহায়তা করে। পরিচিতি সরবরাহকারী নতুন পরিচিতি সারি তৈরি এবং বিদ্যমান পরিচিতি সারির সাথে কাঁচা যোগাযোগের একত্রিতকরণ পরিচালনা করে। অ্যাপ্লিকেশন বা সিঙ্ক অ্যাডাপ্টার উভয়কেই পরিচিতি যুক্ত করার অনুমতি নেই এবং একটি পরিচিতি সারির কিছু কলাম কেবল পঠনযোগ্য।
 দ্রষ্টব্য: যদি আপনি insert() ব্যবহার করে Contacts Provider-এ একটি পরিচিতি যোগ করার চেষ্টা করেন, তাহলে আপনি একটি UnsupportedOperationException ব্যতিক্রম পাবেন। যদি আপনি "read-only" হিসাবে তালিকাভুক্ত একটি কলাম আপডেট করার চেষ্টা করেন, তাহলে আপডেটটি উপেক্ষা করা হবে।
কোনও নতুন কাঁচা পরিচিতি যুক্ত করার প্রতিক্রিয়ায় পরিচিতি সরবরাহকারী একটি নতুন পরিচিতি তৈরি করে যা কোনও বিদ্যমান পরিচিতির সাথে মেলে না। সরবরাহকারীও এটি করে যদি কোনও বিদ্যমান কাঁচা পরিচিতির ডেটা এমনভাবে পরিবর্তিত হয় যে এটি আর সেই পরিচিতির সাথে মেলে না যার সাথে এটি পূর্বে সংযুক্ত ছিল। যদি কোনও অ্যাপ্লিকেশন বা সিঙ্ক অ্যাডাপ্টার একটি নতুন কাঁচা পরিচিতি তৈরি করে যা একটি বিদ্যমান পরিচিতির সাথে মেলে , তবে নতুন কাঁচা পরিচিতিটি বিদ্যমান পরিচিতির সাথে একত্রিত হয়।
 Contacts Provider একটি পরিচিতি সারিকে তার কাঁচা যোগাযোগ সারিগুলির সাথে Contacts টেবিলের _ID কলামের সাথে লিঙ্ক করে। ContactsContract.RawContacts এর কাঁচা যোগাযোগ সারিগুলির CONTACT_ID কলামে প্রতিটি কাঁচা যোগাযোগ সারি সম্পর্কিত পরিচিতি সারিগুলির জন্য _ID মান থাকে।
 ContactsContract.Contacts টেবিলে LOOKUP_KEY কলামটিও রয়েছে যা যোগাযোগের সারির একটি "স্থায়ী" লিঙ্ক। যেহেতু যোগাযোগ সরবরাহকারী স্বয়ংক্রিয়ভাবে পরিচিতিগুলি বজায় রাখে, তাই এটি একটি একত্রিতকরণ বা সিঙ্কের প্রতিক্রিয়ায় একটি যোগাযোগের সারির _ID মান পরিবর্তন করতে পারে। এমনকি যদি এটি ঘটে, তবে URI CONTENT_LOOKUP_URI কন্টেন্টটি পরিচিতির LOOKUP_KEY সাথে মিলিত হয়ে যোগাযোগের সারির দিকে নির্দেশ করবে, তাই আপনি "প্রিয়" পরিচিতিগুলির লিঙ্কগুলি বজায় রাখতে LOOKUP_KEY ব্যবহার করতে পারেন, ইত্যাদি। এই কলামের নিজস্ব ফর্ম্যাট রয়েছে যা _ID কলামের ফর্ম্যাটের সাথে সম্পর্কিত নয়।
চিত্র ৩ দেখায় যে তিনটি প্রধান টেবিল কীভাবে একে অপরের সাথে সম্পর্কিত।

চিত্র ৩। পরিচিতি, কাঁচা পরিচিতি, এবং বিশদ টেবিল সম্পর্ক।
সতর্কতা: যদি আপনি আপনার অ্যাপটি গুগল প্লে স্টোরে প্রকাশ করেন, অথবা যদি আপনার অ্যাপটি অ্যান্ড্রয়েড ১০ (এপিআই লেভেল ২৯) বা তার উচ্চতর ভার্সন চালিত ডিভাইসে থাকে, তাহলে মনে রাখবেন যে সীমিত সংখ্যক পরিচিতি ডেটা ক্ষেত্র এবং পদ্ধতি অপ্রচলিত।
উল্লেখিত শর্তাবলীর অধীনে, সিস্টেমটি পর্যায়ক্রমে এই ডেটা ক্ষেত্রগুলিতে লেখা যেকোনো মান সাফ করে:
-  
ContactsContract.ContactOptionsColumns.LAST_TIME_CONTACTED -  
ContactsContract.ContactOptionsColumns.TIMES_CONTACTED -  
ContactsContract.DataUsageStatColumns.LAST_TIME_USED -  
ContactsContract.DataUsageStatColumns.TIMES_USED 
উপরের ডেটা ফিল্ডগুলি সেট করতে ব্যবহৃত APIগুলিও অপ্রচলিত:
এছাড়াও, নিম্নলিখিত ক্ষেত্রগুলি আর ঘন ঘন পরিচিতি ফেরত দেয় না। মনে রাখবেন যে এই ক্ষেত্রগুলির মধ্যে কিছু কেবল তখনই পরিচিতিগুলির র্যাঙ্কিংকে প্রভাবিত করে যখন পরিচিতিগুলি একটি নির্দিষ্ট ডেটা ধরণের অংশ হয়।
-  
ContactsContract.Contacts.CONTENT_FREQUENT_URI -  
ContactsContract.Contacts.CONTENT_STREQUENT_URI -  
ContactsContract.Contacts.CONTENT_STREQUENT_FILTER_URI -  
CONTENT_FILTER_URI(শুধুমাত্র ইমেল , ফোন , কলযোগ্য এবং যোগাযোগযোগ্য ডেটা প্রকারগুলিকে প্রভাবিত করে) -  
ENTERPRISE_CONTENT_FILTER_URI(শুধুমাত্র ইমেল , ফোন এবং কলযোগ্য ডেটা প্রকারগুলিকে প্রভাবিত করে) 
যদি আপনার অ্যাপগুলি এই ক্ষেত্রগুলি বা API গুলি অ্যাক্সেস বা আপডেট করে, তাহলে বিকল্প পদ্ধতি ব্যবহার করুন। উদাহরণস্বরূপ, আপনি ব্যক্তিগত সামগ্রী সরবরাহকারী বা আপনার অ্যাপ বা ব্যাকএন্ড সিস্টেমের মধ্যে সংরক্ষিত অন্যান্য ডেটা ব্যবহার করে নির্দিষ্ট ব্যবহারের ক্ষেত্রে পূরণ করতে পারেন।
এই পরিবর্তনের ফলে আপনার অ্যাপের কার্যকারিতা প্রভাবিত হচ্ছে না তা যাচাই করতে, আপনি এই ডেটা ফিল্ডগুলি ম্যানুয়ালি সাফ করতে পারেন। এটি করার জন্য, Android 4.1 (API লেভেল 16) বা উচ্চতর ভার্সন চলমান ডিভাইসে নিম্নলিখিত ADB কমান্ডটি চালান:
adb shell content delete \ --uri content://com.android.contacts/contacts/delete_usage
সিঙ্ক অ্যাডাপ্টার থেকে ডেটা
 ব্যবহারকারীরা সরাসরি ডিভাইসে পরিচিতি ডেটা প্রবেশ করান, তবে সিঙ্ক অ্যাডাপ্টারের মাধ্যমে ওয়েব পরিষেবা থেকে পরিচিতি সরবরাহকারীতেও ডেটা প্রবাহিত হয়, যা ডিভাইস এবং পরিষেবার মধ্যে ডেটা স্থানান্তর স্বয়ংক্রিয় করে। সিঙ্ক অ্যাডাপ্টারগুলি সিস্টেমের নিয়ন্ত্রণে পটভূমিতে চলে এবং তারা ডেটা পরিচালনা করার জন্য ContentResolver পদ্ধতি ব্যবহার করে।
অ্যান্ড্রয়েডে, একটি সিঙ্ক অ্যাডাপ্টার যে ওয়েব পরিষেবার সাথে কাজ করে তা একটি অ্যাকাউন্টের ধরণ দ্বারা চিহ্নিত করা হয়। প্রতিটি সিঙ্ক অ্যাডাপ্টার একটি অ্যাকাউন্টের ধরণ দিয়ে কাজ করে, তবে এটি সেই ধরণের জন্য একাধিক অ্যাকাউন্টের নাম সমর্থন করতে পারে। অ্যাকাউন্টের ধরণ এবং অ্যাকাউন্টের নামগুলি কাঁচা যোগাযোগের ডেটার উৎস বিভাগে সংক্ষেপে বর্ণনা করা হয়েছে। নিম্নলিখিত সংজ্ঞাগুলি আরও বিশদ প্রদান করে এবং বর্ণনা করে যে অ্যাকাউন্টের ধরণ এবং নাম কীভাবে সিঙ্ক অ্যাডাপ্টার এবং পরিষেবার সাথে সম্পর্কিত।
- অ্যাকাউন্টের ধরণ
 -  ব্যবহারকারীর ডেটা সংরক্ষণ করা আছে এমন একটি পরিষেবা সনাক্ত করে। বেশিরভাগ সময়, ব্যবহারকারীকে পরিষেবাটির সাথে প্রমাণীকরণ করতে হয়। উদাহরণস্বরূপ, Google Contacts হল একটি অ্যাকাউন্টের ধরণ, যা 
google.comকোড দ্বারা চিহ্নিত করা হয়। এই মানটিAccountManagerদ্বারা ব্যবহৃত অ্যাকাউন্টের ধরণের সাথে মিলে যায়। - অ্যাকাউন্টের নাম
 - একটি নির্দিষ্ট অ্যাকাউন্ট বা অ্যাকাউন্ট ধরণের জন্য লগইন শনাক্ত করে। গুগল কন্টাক্টস অ্যাকাউন্টগুলি গুগল অ্যাকাউন্টগুলির মতোই, যার অ্যাকাউন্টের নামের সাথে একটি ইমেল ঠিকানা থাকে। অন্যান্য পরিষেবাগুলি একটি একক-শব্দ ব্যবহারকারীর নাম বা সংখ্যাসূচক আইডি ব্যবহার করতে পারে।
 
অ্যাকাউন্টের ধরণগুলি অনন্য হতে হবে না। একজন ব্যবহারকারী একাধিক Google Contacts অ্যাকাউন্ট কনফিগার করতে পারেন এবং Contacts Provider-এ তাদের ডেটা ডাউনলোড করতে পারেন; এটি ঘটতে পারে যদি ব্যবহারকারীর ব্যক্তিগত অ্যাকাউন্টের নামের জন্য এক সেট ব্যক্তিগত পরিচিতি থাকে এবং অন্য সেট কাজের জন্য থাকে। অ্যাকাউন্টের নামগুলি সাধারণত অনন্য। একসাথে, তারা Contacts Provider এবং একটি বহিরাগত পরিষেবার মধ্যে একটি নির্দিষ্ট ডেটা প্রবাহ সনাক্ত করে।
যদি আপনি আপনার পরিষেবার ডেটা পরিচিতি সরবরাহকারীর কাছে স্থানান্তর করতে চান, তাহলে আপনাকে নিজের সিঙ্ক অ্যাডাপ্টার লিখতে হবে। এটি "পরিচিতি সরবরাহকারী সিঙ্ক অ্যাডাপ্টার" বিভাগে আরও বিশদে বর্ণনা করা হয়েছে।
চিত্র ৪-এ দেখানো হয়েছে কিভাবে পরিচিতি প্রদানকারী মানুষের তথ্য প্রবাহের সাথে খাপ খায়। "সিঙ্ক অ্যাডাপ্টার" চিহ্নিত বাক্সে, প্রতিটি অ্যাডাপ্টারকে তার অ্যাকাউন্টের ধরণ অনুসারে লেবেল করা হয়েছে।

চিত্র ৪। যোগাযোগ সরবরাহকারীর তথ্য প্রবাহ।
প্রয়োজনীয় অনুমতি
যেসব অ্যাপ্লিকেশন পরিচিতি প্রদানকারী অ্যাক্সেস করতে চায় তাদের নিম্নলিখিত অনুমতিগুলির জন্য অনুরোধ করতে হবে:
- এক বা একাধিক টেবিলে পড়ার অ্যাক্সেস
 -  
READ_CONTACTS,AndroidManifest.xmlএ<uses-permission>উপাদান হিসেবে উল্লেখ করা হয়েছে<uses-permission android:name="android.permission.READ_CONTACTS"> - এক বা একাধিক টেবিলে লেখার অ্যাক্সেস
 -  
WRITE_CONTACTS,AndroidManifest.xmlএ<uses-permission>উপাদানটি<uses-permission android:name="android.permission.WRITE_CONTACTS">হিসাবে উল্লেখ করা হয়েছে। 
এই অনুমতিগুলি ব্যবহারকারীর প্রোফাইল ডেটাতে প্রসারিত হয় না। ব্যবহারকারীর প্রোফাইল এবং এর প্রয়োজনীয় অনুমতিগুলি নিম্নলিখিত বিভাগে, ব্যবহারকারীর প্রোফাইলে আলোচনা করা হয়েছে।
মনে রাখবেন যে ব্যবহারকারীর পরিচিতি তথ্য ব্যক্তিগত এবং সংবেদনশীল। ব্যবহারকারীরা তাদের গোপনীয়তা নিয়ে উদ্বিগ্ন, তাই তারা চান না যে অ্যাপ্লিকেশনগুলি তাদের বা তাদের পরিচিতি সম্পর্কে তথ্য সংগ্রহ করুক। যদি স্পষ্ট না হয় যে কেন তাদের পরিচিতি তথ্য অ্যাক্সেস করার জন্য আপনার অনুমতি প্রয়োজন, তাহলে তারা আপনার অ্যাপ্লিকেশনটিকে কম রেটিং দিতে পারে অথবা এটি ইনস্টল করতে অস্বীকার করতে পারে।
ব্যবহারকারীর প্রোফাইল
 ContactsContract.Contacts টেবিলে ডিভাইসের ব্যবহারকারীর প্রোফাইল ডেটা সম্বলিত একটি একক সারি রয়েছে। এই ডেটা ব্যবহারকারীর পরিচিতিগুলির মধ্যে একটির পরিবর্তে ডিভাইসের user বর্ণনা করে। প্রোফাইল পরিচিতি সারিটি প্রতিটি সিস্টেমের জন্য একটি raw পরিচিতি সারির সাথে সংযুক্ত থাকে যা একটি প্রোফাইল ব্যবহার করে। প্রতিটি প্রোফাইল raw পরিচিতি সারিতে একাধিক ডেটা সারি থাকতে পারে। ব্যবহারকারীর প্রোফাইল অ্যাক্সেস করার জন্য ধ্রুবকগুলি ContactsContract.Profile ক্লাসে উপলব্ধ।
 ব্যবহারকারীর প্রোফাইলে অ্যাক্সেসের জন্য বিশেষ অনুমতি প্রয়োজন। পড়া এবং লেখার জন্য প্রয়োজনীয় READ_CONTACTS এবং WRITE_CONTACTS অনুমতি ছাড়াও, ব্যবহারকারীর প্রোফাইলে অ্যাক্সেসের জন্য যথাক্রমে পড়া এবং লেখার অ্যাক্সেসের জন্য android.Manifest.permission#READ_PROFILE এবং android.Manifest.permission#WRITE_PROFILE অনুমতি প্রয়োজন।
মনে রাখবেন যে আপনার একজন ব্যবহারকারীর প্রোফাইলকে সংবেদনশীল হিসেবে বিবেচনা করা উচিত। android.Manifest.permission#READ_PROFILE অনুমতি আপনাকে ডিভাইস ব্যবহারকারীর ব্যক্তিগতভাবে সনাক্তকারী ডেটা অ্যাক্সেস করার অনুমতি দেয়। আপনার অ্যাপ্লিকেশনের বর্ণনায় ব্যবহারকারীকে কেন ব্যবহারকারীর প্রোফাইল অ্যাক্সেসের অনুমতি প্রয়োজন তা অবশ্যই বলুন।
 ব্যবহারকারীর প্রোফাইল ধারণকারী পরিচিতি সারিটি পুনরুদ্ধার করতে, ContentResolver.query() কল করুন। কন্টেন্ট URI কে CONTENT_URI তে সেট করুন এবং কোনও নির্বাচনের মানদণ্ড প্রদান করবেন না। আপনি প্রোফাইলের জন্য কাঁচা পরিচিতি বা ডেটা পুনরুদ্ধারের জন্য এই কন্টেন্ট URI কে বেস URI হিসাবেও ব্যবহার করতে পারেন। উদাহরণস্বরূপ, এই স্নিপেটটি প্রোফাইলের জন্য ডেটা পুনরুদ্ধার করে: 
কোটলিন
// Sets the columns to retrieve for the user profile projection = arrayOf( ContactsContract.Profile._ID, ContactsContract.Profile.DISPLAY_NAME_PRIMARY, ContactsContract.Profile.LOOKUP_KEY, ContactsContract.Profile.PHOTO_THUMBNAIL_URI ) // Retrieves the profile from the Contacts Provider profileCursor = contentResolver.query( ContactsContract.Profile.CONTENT_URI, projection, null, null, null )
জাভা
// Sets the columns to retrieve for the user profile projection = new String[] { Profile._ID, Profile.DISPLAY_NAME_PRIMARY, Profile.LOOKUP_KEY, Profile.PHOTO_THUMBNAIL_URI }; // Retrieves the profile from the Contacts Provider profileCursor = getContentResolver().query( Profile.CONTENT_URI, projection , null, null, null);
 দ্রষ্টব্য: যদি আপনি একাধিক পরিচিতি সারি পুনরুদ্ধার করেন এবং আপনি নির্ধারণ করতে চান যে তাদের মধ্যে একটি ব্যবহারকারীর প্রোফাইল কিনা, তাহলে সারির IS_USER_PROFILE কলামটি পরীক্ষা করুন। যদি পরিচিতিটি ব্যবহারকারীর প্রোফাইল হয় তবে এই কলামটি "1" তে সেট করা আছে।
পরিচিতি প্রদানকারীর মেটাডেটা
 Contacts Provider ডেটা পরিচালনা করে যা রিপোজিটরিতে থাকা কন্টাক্ট ডেটার অবস্থা ট্র্যাক করে। রিপোজিটরি সম্পর্কে এই মেটাডেটা বিভিন্ন স্থানে সংরক্ষণ করা হয়, যার মধ্যে রয়েছে Raw Contacts, Data, এবং Contacts টেবিলের সারি, ContactsContract.Settings টেবিল এবং ContactsContract.SyncState টেবিল। নিম্নলিখিত টেবিলটি এই প্রতিটি মেটাডেটার প্রভাব দেখায়:
সারণি ৩। পরিচিতি সরবরাহকারীর মেটাডেটা
| টেবিল | কলাম | মূল্যবোধ | অর্থ | 
|---|---|---|---|
 ContactsContract.RawContacts |  DIRTY | "0" - শেষ সিঙ্কের পর থেকে পরিবর্তন হয়নি। |  ডিভাইসে পরিবর্তিত এবং সার্ভারে সিঙ্ক করতে হয় এমন কাঁচা পরিচিতিগুলিকে চিহ্নিত করে। অ্যান্ড্রয়েড অ্যাপ্লিকেশনগুলি যখন একটি সারি আপডেট করে তখন পরিচিতি সরবরাহকারী দ্বারা মানটি স্বয়ংক্রিয়ভাবে সেট করা হয়।  যেসব সিঙ্ক অ্যাডাপ্টার কাঁচা যোগাযোগ বা ডেটা টেবিল পরিবর্তন করে, তাদের সর্বদা তাদের ব্যবহৃত কন্টেন্ট URI-তে   | 
| "1" - শেষ সিঙ্কের পর থেকে পরিবর্তিত হয়েছে, সার্ভারে আবার সিঙ্ক করতে হবে। | |||
 ContactsContract.RawContacts |  VERSION | এই সারির সংস্করণ নম্বর। | যখনই সারি বা এর সাথে সম্পর্কিত ডেটা পরিবর্তন হয়, তখন যোগাযোগ সরবরাহকারী স্বয়ংক্রিয়ভাবে এই মানটি বৃদ্ধি করে। | 
 ContactsContract.Data |  DATA_VERSION | এই সারির সংস্করণ নম্বর। | যখনই ডেটা সারি পরিবর্তন করা হয়, তখন যোগাযোগ সরবরাহকারী স্বয়ংক্রিয়ভাবে এই মানটি বৃদ্ধি করে। | 
 ContactsContract.RawContacts |  SOURCE_ID | একটি স্ট্রিং মান যা এই কাঁচা পরিচিতিকে অনন্যভাবে সেই অ্যাকাউন্টের সাথে শনাক্ত করে যেখানে এটি তৈরি করা হয়েছিল। |  যখন একটি সিঙ্ক অ্যাডাপ্টার একটি নতুন raw পরিচিতি তৈরি করে, তখন এই কলামটি raw পরিচিতির জন্য সার্ভারের অনন্য ID তে সেট করা উচিত। যখন একটি Android অ্যাপ্লিকেশন একটি নতুন raw পরিচিতি তৈরি করে, তখন অ্যাপ্লিকেশনটি এই কলামটি খালি রাখা উচিত। এটি সিঙ্ক অ্যাডাপ্টারকে সংকেত দেয় যে এটি সার্ভারে একটি নতুন raw পরিচিতি তৈরি করবে এবং SOURCE_ID এর জন্য একটি মান পাবে।বিশেষ করে, প্রতিটি অ্যাকাউন্টের ধরণের জন্য সোর্স আইডি অবশ্যই অনন্য হতে হবে এবং সিঙ্ক জুড়ে স্থিতিশীল থাকতে হবে: 
  | 
 ContactsContract.Groups |  GROUP_VISIBLE | "0" - এই গ্রুপের পরিচিতিগুলি অ্যান্ড্রয়েড অ্যাপ্লিকেশন UI তে দৃশ্যমান হওয়া উচিত নয়। | এই কলামটি এমন সার্ভারগুলির সাথে সামঞ্জস্যের জন্য যা ব্যবহারকারীকে নির্দিষ্ট গোষ্ঠীতে পরিচিতি লুকানোর অনুমতি দেয়। | 
| "১" - এই গোষ্ঠীর পরিচিতিগুলি অ্যাপ্লিকেশন UI তে দৃশ্যমান হওয়ার অনুমতিপ্রাপ্ত। | |||
 ContactsContract.Settings |  UNGROUPED_VISIBLE | "0" - এই অ্যাকাউন্ট এবং অ্যাকাউন্টের ধরণের জন্য, যে পরিচিতিগুলি কোনও গোষ্ঠীর অন্তর্গত নয় সেগুলি অ্যান্ড্রয়েড অ্যাপ্লিকেশন UI-তে অদৃশ্য থাকে। |  ডিফল্টরূপে, যদি তাদের কোনও কাঁচা পরিচিতি কোনও গোষ্ঠীর অন্তর্ভুক্ত না হয় তবে পরিচিতিগুলি অদৃশ্য থাকে (একটি কাঁচা পরিচিতির জন্য গ্রুপ সদস্যপদ ContactsContract.Data টেবিলে এক বা একাধিক ContactsContract.CommonDataKinds.GroupMembership সারি দ্বারা নির্দেশিত হয়)। অ্যাকাউন্টের ধরণ এবং অ্যাকাউন্টের জন্য ContactsContract.Settings টেবিল সারিতে এই পতাকাটি সেট করে, আপনি গ্রুপ ছাড়া পরিচিতিগুলিকে দৃশ্যমান করতে বাধ্য করতে পারেন। এই পতাকার একটি ব্যবহার হল এমন সার্ভার থেকে পরিচিতিগুলি দেখানো যারা গ্রুপ ব্যবহার করে না। | 
| "1" - এই অ্যাকাউন্ট এবং অ্যাকাউন্টের ধরণের জন্য, যে পরিচিতিগুলি কোনও গোষ্ঠীর অন্তর্গত নয় সেগুলি অ্যাপ্লিকেশন UI-তে দৃশ্যমান। | |||
 ContactsContract.SyncState | (সব) | আপনার সিঙ্ক অ্যাডাপ্টারের জন্য মেটাডেটা সংরক্ষণ করতে এই টেবিলটি ব্যবহার করুন। | এই টেবিলের সাহায্যে আপনি ডিভাইসে সিঙ্ক অবস্থা এবং অন্যান্য সিঙ্ক-সম্পর্কিত ডেটা স্থায়ীভাবে সংরক্ষণ করতে পারবেন। | 
যোগাযোগ প্রদানকারীর অ্যাক্সেস
এই বিভাগটি যোগাযোগ সরবরাহকারীর ডেটা অ্যাক্সেস করার জন্য নির্দেশিকা বর্ণনা করে, নিম্নলিখিত বিষয়গুলির উপর আলোকপাত করে:
- সত্তার প্রশ্ন।
 - ব্যাচ পরিবর্তন।
 - উদ্দেশ্য সহ পুনরুদ্ধার এবং পরিবর্তন।
 - তথ্যের অখণ্ডতা।
 
সিঙ্ক অ্যাডাপ্টার থেকে পরিবর্তন করার বিষয়টি "কন্টাক্টস প্রোভাইডার সিঙ্ক অ্যাডাপ্টার" বিভাগে আরও বিস্তারিতভাবে আলোচনা করা হয়েছে।
সত্তা অনুসন্ধান করা হচ্ছে
 যেহেতু Contacts Provider টেবিলগুলি একটি শ্রেণিবিন্যাসে সংগঠিত, তাই প্রায়শই একটি সারি এবং এর সাথে সংযুক্ত সমস্ত "শিশু" সারি পুনরুদ্ধার করা কার্যকর। উদাহরণস্বরূপ, একজন ব্যক্তির জন্য সমস্ত তথ্য প্রদর্শনের জন্য, আপনি একটি একক ContactsContract.Contacts সারির জন্য সমস্ত ContactsContract.RawContacts সারি, অথবা একটি একক ContactsContract.RawContacts সারির জন্য সমস্ত ContactsContract.CommonDataKinds.Email সারি পুনরুদ্ধার করতে চাইতে পারেন। এটি সহজতর করার জন্য, Contacts Provider সত্তা গঠন অফার করে, যা টেবিলের মধ্যে ডাটাবেস সংযোগের মতো কাজ করে।
 একটি সত্তা হল একটি টেবিলের মতো যা একটি প্যারেন্ট টেবিল এবং তার চাইল্ড টেবিল থেকে নির্বাচিত কলামগুলির সমন্বয়ে গঠিত। যখন আপনি একটি সত্তাকে জিজ্ঞাসা করেন, তখন আপনি সত্তা থেকে উপলব্ধ কলামগুলির উপর ভিত্তি করে একটি প্রক্ষেপণ এবং অনুসন্ধানের মানদণ্ড সরবরাহ করেন। ফলাফল হল একটি Cursor যাতে পুনরুদ্ধার করা প্রতিটি চাইল্ড টেবিল সারির জন্য একটি সারি থাকে। উদাহরণস্বরূপ, যদি আপনি একটি পরিচিতির নাম এবং সেই নামের জন্য সমস্ত কাঁচা পরিচিতির জন্য সমস্ত ContactsContract.Contacts.Entity ContactsContract.CommonDataKinds.Email অনুসন্ধান করেন, তাহলে আপনি প্রতিটি ContactsContract.CommonDataKinds.Email সারি সহ একটি Cursor পাবেন।
সত্তাগুলি কোয়েরি সহজ করে। একটি সত্তা ব্যবহার করে, আপনি একটি পরিচিতি বা কাঁচা পরিচিতির জন্য সমস্ত পরিচিতি ডেটা একবারে পুনরুদ্ধার করতে পারেন, প্রথমে একটি আইডি পেতে প্যারেন্ট টেবিলটি জিজ্ঞাসা করার পরিবর্তে, এবং তারপরে সেই আইডি দিয়ে চাইল্ড টেবিলটি জিজ্ঞাসা করতে হবে। এছাড়াও, পরিচিতি সরবরাহকারী একটি একক লেনদেনে একটি সত্তার বিরুদ্ধে একটি কোয়েরি প্রক্রিয়া করে, যা নিশ্চিত করে যে পুনরুদ্ধার করা ডেটা অভ্যন্তরীণভাবে সামঞ্জস্যপূর্ণ।
 দ্রষ্টব্য: একটি সত্তা সাধারণত প্যারেন্ট এবং চাইল্ড টেবিলের সমস্ত কলাম ধারণ করে না। যদি আপনি এমন একটি কলামের নাম নিয়ে কাজ করার চেষ্টা করেন যা সত্তার জন্য কলামের নামের ধ্রুবকের তালিকায় নেই, তাহলে আপনি একটি Exception পাবেন।
 নিম্নলিখিত স্নিপেটে একটি পরিচিতির জন্য সমস্ত কাঁচা যোগাযোগের সারি কীভাবে পুনরুদ্ধার করতে হয় তা দেখানো হয়েছে। স্নিপেটটি একটি বৃহত্তর অ্যাপ্লিকেশনের অংশ যার দুটি কার্যকলাপ রয়েছে, "প্রধান" এবং "বিস্তারিত"। প্রধান কার্যকলাপটি যোগাযোগের সারিগুলির একটি তালিকা দেখায়; যখন ব্যবহারকারী একটি নির্বাচন করেন, তখন কার্যকলাপটি তার আইডি বিস্তারিত কার্যকলাপে পাঠায়। বিস্তারিত কার্যকলাপটি নির্বাচিত পরিচিতির সাথে সম্পর্কিত সমস্ত কাঁচা যোগাযোগের সমস্ত ডেটা সারি প্রদর্শন করতে ContactsContract.Contacts.Entity ব্যবহার করে।
এই স্নিপেটটি "বিস্তারিত" কার্যকলাপ থেকে নেওয়া হয়েছে:
কোটলিন
... /* * Appends the entity path to the URI. In the case of the Contacts Provider, the * expected URI is content://com.google.contacts/#/entity (# is the ID value). */ contactUri = Uri.withAppendedPath( contactUri, ContactsContract.Contacts.Entity.CONTENT_DIRECTORY ) // Initializes the loader identified by LOADER_ID. loaderManager.initLoader( LOADER_ID, // The identifier of the loader to initialize null, // Arguments for the loader (in this case, none) this // The context of the activity ) // Creates a new cursor adapter to attach to the list view cursorAdapter = SimpleCursorAdapter( this, // the context of the activity R.layout.detail_list_item, // the view item containing the detail widgets mCursor, // the backing cursor fromColumns, // the columns in the cursor that provide the data toViews, // the views in the view item that display the data 0) // flags // Sets the ListView's backing adapter. rawContactList.adapter = cursorAdapter ... override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> { /* * Sets the columns to retrieve. * RAW_CONTACT_ID is included to identify the raw contact associated with the data row. * DATA1 contains the first column in the data row (usually the most important one). * MIMETYPE indicates the type of data in the data row. */ val projection: Array<String> = arrayOf( ContactsContract.Contacts.Entity.RAW_CONTACT_ID, ContactsContract.Contacts.Entity.DATA1, ContactsContract.Contacts.Entity.MIMETYPE ) /* * Sorts the retrieved cursor by raw contact id, to keep all data rows for a single raw * contact collated together. */ val sortOrder = "${ContactsContract.Contacts.Entity.RAW_CONTACT_ID} ASC" /* * Returns a new CursorLoader. The arguments are similar to * ContentResolver.query(), except for the Context argument, which supplies the location of * the ContentResolver to use. */ return CursorLoader( applicationContext, // The activity's context contactUri, // The entity content URI for a single contact projection, // The columns to retrieve null, // Retrieve all the raw contacts and their data rows. null, // sortOrder // Sort by the raw contact ID. ) }
জাভা
... /* * Appends the entity path to the URI. In the case of the Contacts Provider, the * expected URI is content://com.google.contacts/#/entity (# is the ID value). */ contactUri = Uri.withAppendedPath( contactUri, ContactsContract.Contacts.Entity.CONTENT_DIRECTORY); // Initializes the loader identified by LOADER_ID. getLoaderManager().initLoader( LOADER_ID, // The identifier of the loader to initialize null, // Arguments for the loader (in this case, none) this); // The context of the activity // Creates a new cursor adapter to attach to the list view cursorAdapter = new SimpleCursorAdapter( this, // the context of the activity R.layout.detail_list_item, // the view item containing the detail widgets mCursor, // the backing cursor fromColumns, // the columns in the cursor that provide the data toViews, // the views in the view item that display the data 0); // flags // Sets the ListView's backing adapter. rawContactList.setAdapter(cursorAdapter); ... @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { /* * Sets the columns to retrieve. * RAW_CONTACT_ID is included to identify the raw contact associated with the data row. * DATA1 contains the first column in the data row (usually the most important one). * MIMETYPE indicates the type of data in the data row. */ String[] projection = { ContactsContract.Contacts.Entity.RAW_CONTACT_ID, ContactsContract.Contacts.Entity.DATA1, ContactsContract.Contacts.Entity.MIMETYPE }; /* * Sorts the retrieved cursor by raw contact id, to keep all data rows for a single raw * contact collated together. */ String sortOrder = ContactsContract.Contacts.Entity.RAW_CONTACT_ID + " ASC"; /* * Returns a new CursorLoader. The arguments are similar to * ContentResolver.query(), except for the Context argument, which supplies the location of * the ContentResolver to use. */ return new CursorLoader( getApplicationContext(), // The activity's context contactUri, // The entity content URI for a single contact projection, // The columns to retrieve null, // Retrieve all the raw contacts and their data rows. null, // sortOrder); // Sort by the raw contact ID. }
 লোড শেষ হয়ে গেলে, LoaderManager onLoadFinished() এ একটি কলব্যাক আহ্বান করে। এই পদ্ধতিতে আগত আর্গুমেন্টগুলির মধ্যে একটি হল কোয়েরির ফলাফল সহ একটি Cursor । আপনার নিজস্ব অ্যাপে, আপনি এই Cursor থেকে ডেটা পেতে পারেন যাতে এটি প্রদর্শন করা যায় বা এটির সাথে আরও কাজ করা যায়।
ব্যাচ পরিবর্তন
 যখনই সম্ভব, আপনার Contacts Provider-এ "batch mode"-এ ডেটা সন্নিবেশ করা, আপডেট করা এবং মুছে ফেলা উচিত, ContentProviderOperation অবজেক্টের একটি ArrayList তৈরি করে এবং applyBatch() কল করে। যেহেতু Contacts Provider একটি applyBatch() এর সমস্ত ক্রিয়াকলাপ একটি একক লেনদেনে সম্পাদন করে, তাই আপনার পরিবর্তনগুলি কখনই যোগাযোগ সংগ্রহস্থলকে একটি অসঙ্গত অবস্থায় রাখবে না। একটি ব্যাচ পরিবর্তন একই সময়ে একটি কাঁচা যোগাযোগ এবং এর বিস্তারিত ডেটা সন্নিবেশ করা সহজ করে তোলে।
দ্রষ্টব্য: একটি একক কাঁচা পরিচিতি পরিবর্তন করতে, আপনার অ্যাপে পরিবর্তনটি পরিচালনা করার পরিবর্তে ডিভাইসের পরিচিতি অ্যাপ্লিকেশনে একটি অভিপ্রায় পাঠানোর কথা বিবেচনা করুন। এটি করার বিষয়ে "উদ্ধার এবং অভিপ্রায় সহ পরিবর্তন" বিভাগে আরও বিশদে বর্ণনা করা হয়েছে।
ফলন পয়েন্ট
 একটি ব্যাচ মডিফিকেশন যেখানে প্রচুর সংখ্যক অপারেশন থাকে, তা অন্যান্য প্রসেস ব্লক করতে পারে, যার ফলে সামগ্রিক ব্যবহারকারীর অভিজ্ঞতা খারাপ হতে পারে। যতটা সম্ভব কম সংখ্যক আলাদা তালিকায় আপনি যে পরিবর্তনগুলি সম্পাদন করতে চান তা সংগঠিত করতে এবং একই সাথে সিস্টেম ব্লক করা থেকে বিরত রাখতে, আপনার এক বা একাধিক অপারেশনের জন্য ইল্ড পয়েন্ট সেট করা উচিত। ইল্ড পয়েন্ট হল একটি ContentProviderOperation অবজেক্ট যার isYieldAllowed() মান true তে সেট করা থাকে। যখন Contacts Provider একটি ইল্ড পয়েন্টের মুখোমুখি হয়, তখন এটি অন্যান্য প্রসেসগুলিকে চলতে দেওয়ার জন্য তার কাজ থামিয়ে দেয় এবং বর্তমান লেনদেন বন্ধ করে দেয়। যখন প্রোভাইডার আবার শুরু করে, তখন এটি ArrayList এ পরবর্তী অপারেশন চালিয়ে যায় এবং একটি নতুন লেনদেন শুরু করে।
 Yield points এর ফলে applyBatch() প্রতি কলে একাধিক লেনদেন হয়। এই কারণে, আপনার সম্পর্কিত সারির একটি সেটের জন্য শেষ অপারেশনের জন্য একটি yield point সেট করা উচিত। উদাহরণস্বরূপ, আপনার একটি সেটের শেষ অপারেশনের জন্য একটি yield point সেট করা উচিত যা একটি raw contact rows এবং এর সাথে সম্পর্কিত ডেটা rows যোগ করে, অথবা একটি একক contact এর সাথে সম্পর্কিত সারির একটি সেটের জন্য শেষ অপারেশন।
ফলন বিন্দুও পারমাণবিক ক্রিয়াকলাপের একটি একক। দুটি ফলন বিন্দুর মধ্যে সমস্ত অ্যাক্সেস একক ইউনিট হিসাবে সফল হবে অথবা ব্যর্থ হবে। যদি আপনি কোনও ফলন বিন্দু সেট না করেন, তাহলে সবচেয়ে ছোট পারমাণবিক ক্রিয়াকলাপ হল সম্পূর্ণ ব্যাচের ক্রিয়াকলাপ। আপনি যদি ফলন বিন্দু ব্যবহার করেন, তাহলে আপনি অপারেশনগুলিকে সিস্টেমের কর্মক্ষমতা হ্রাস করা থেকে বিরত রাখবেন, একই সাথে নিশ্চিত করবেন যে অপারেশনগুলির একটি উপসেট পারমাণবিক।
সংশোধনের পিছনের রেফারেন্সগুলি
 যখন আপনি একটি নতুন কাঁচা যোগাযোগ সারি এবং এর সাথে সম্পর্কিত ডেটা সারিগুলিকে ContentProviderOperation অবজেক্টের সেট হিসেবে সন্নিবেশ করান, তখন আপনাকে কাঁচা যোগাযোগের _ID মানটি RAW_CONTACT_ID মান হিসেবে সন্নিবেশ করে কাঁচা যোগাযোগের সারির সাথে ডেটা সারিগুলিকে লিঙ্ক করতে হবে। তবে, ডেটা সারির জন্য ContentProviderOperation তৈরি করার সময় এই মানটি উপলব্ধ থাকে না, কারণ আপনি এখনও কাঁচা যোগাযোগের সারির জন্য ContentProviderOperation প্রয়োগ করেননি। এটি সমাধানের জন্য, ContentProviderOperation.Builder ক্লাসে withValueBackReference() পদ্ধতি রয়েছে। এই পদ্ধতিটি আপনাকে পূর্ববর্তী ক্রিয়াকলাপের ফলাফল সহ একটি কলাম সন্নিবেশ বা পরিবর্তন করতে দেয়।
 withValueBackReference() পদ্ধতিতে দুটি আর্গুমেন্ট রয়েছে:
-  
key - একটি কী-মান জোড়ার কী। এই আর্গুমেন্টের মানটি আপনার পরিবর্তন করা টেবিলের একটি কলামের নাম হওয়া উচিত।
 -  
previousResult -  
applyBatch()থেকেContentProviderResultঅবজেক্টের অ্যারেতে থাকা একটি মানের 0-ভিত্তিক সূচক। ব্যাচ অপারেশনগুলি প্রয়োগ করার সাথে সাথে, প্রতিটি অপারেশনের ফলাফল ফলাফলের একটি মধ্যবর্তী অ্যারেতে সংরক্ষণ করা হয়।previousResultমান হল এই ফলাফলগুলির একটির সূচক, যা পুনরুদ্ধার করা হয় এবংkeyমানের সাথে সংরক্ষণ করা হয়। এটি আপনাকে একটি নতুন কাঁচা যোগাযোগ রেকর্ড সন্নিবেশ করতে এবং এর_IDমান ফিরে পেতে দেয়, তারপরContactsContract.Dataসারি যোগ করার সময় মানটিতে একটি "ব্যাক রেফারেন্স" তৈরি করে।যখন আপনি প্রথম
applyBatch()কল করেন তখন সম্পূর্ণ ফলাফল অ্যারে তৈরি হয়, যার আকার আপনার প্রদত্তArrayListofContentProviderOperationঅবজেক্টের আকারের সমান হয়। যাইহোক, ফলাফল অ্যারের সমস্ত উপাদানnullএ সেট করা থাকে, এবং যদি আপনি এমন একটি অপারেশনের জন্য ফলাফলের পিছনে রেফারেন্স করার চেষ্টা করেন যা এখনও প্রয়োগ করা হয়নি, তাহলেwithValueBackReference()একটিExceptionফেলে দেয়। 
নিম্নলিখিত স্নিপেটগুলি দেখায় কিভাবে ব্যাচে একটি নতুন কাঁচা পরিচিতি এবং ডেটা সন্নিবেশ করানো যায়। এগুলিতে এমন কোড রয়েছে যা একটি ফলন বিন্দু স্থাপন করে এবং একটি ব্যাক রেফারেন্স ব্যবহার করে।
প্রথম স্নিপেটটি UI থেকে যোগাযোগের তথ্য উদ্ধার করে। এই মুহুর্তে, ব্যবহারকারী ইতিমধ্যেই সেই অ্যাকাউন্টটি নির্বাচন করেছেন যার জন্য নতুন কাঁচা পরিচিতি যোগ করা উচিত।
কোটলিন
// Creates a contact entry from the current UI values, using the currently-selected account. private fun createContactEntry() { /* * Gets values from the UI */ val name = contactNameEditText.text.toString() val phone = contactPhoneEditText.text.toString() val email = contactEmailEditText.text.toString() val phoneType: String = contactPhoneTypes[mContactPhoneTypeSpinner.selectedItemPosition] val emailType: String = contactEmailTypes[mContactEmailTypeSpinner.selectedItemPosition]
জাভা
// Creates a contact entry from the current UI values, using the currently-selected account. protected void createContactEntry() { /* * Gets values from the UI */ String name = contactNameEditText.getText().toString(); String phone = contactPhoneEditText.getText().toString(); String email = contactEmailEditText.getText().toString(); int phoneType = contactPhoneTypes.get( contactPhoneTypeSpinner.getSelectedItemPosition()); int emailType = contactEmailTypes.get( contactEmailTypeSpinner.getSelectedItemPosition());
 পরবর্তী স্নিপেটটি ContactsContract.RawContacts টেবিলে কাঁচা যোগাযোগের সারি সন্নিবেশ করার জন্য একটি অপারেশন তৈরি করে: 
কোটলিন
/* * Prepares the batch operation for inserting a new raw contact and its data. Even if * the Contacts Provider does not have any data for this person, you can't add a Contact, * only a raw contact. The Contacts Provider will then add a Contact automatically. */ // Creates a new array of ContentProviderOperation objects. val ops = arrayListOf<ContentProviderOperation>() /* * Creates a new raw contact with its account type (server type) and account name * (user's account). Remember that the display name is not stored in this row, but in a * StructuredName data row. No other data is required. */ var op: ContentProviderOperation.Builder = ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, selectedAccount.name) .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, selectedAccount.type) // Builds the operation and adds it to the array of operations ops.add(op.build())
জাভা
/* * Prepares the batch operation for inserting a new raw contact and its data. Even if * the Contacts Provider does not have any data for this person, you can't add a Contact, * only a raw contact. The Contacts Provider will then add a Contact automatically. */ // Creates a new array of ContentProviderOperation objects. ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); /* * Creates a new raw contact with its account type (server type) and account name * (user's account). Remember that the display name is not stored in this row, but in a * StructuredName data row. No other data is required. */ ContentProviderOperation.Builder op = ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, selectedAccount.getType()) .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, selectedAccount.getName()); // Builds the operation and adds it to the array of operations ops.add(op.build());
এরপর, কোডটি প্রদর্শনের নাম, ফোন এবং ইমেল সারির জন্য ডেটা সারি তৈরি করে।
 প্রতিটি অপারেশন বিল্ডার অবজেক্ট RAW_CONTACT_ID পেতে withValueBackReference() ব্যবহার করে। রেফারেন্সটি প্রথম অপারেশন থেকে ContentProviderResult অবজেক্টের দিকে নির্দেশ করে, যা raw contact row যোগ করে এবং এর নতুন _ID মান ফেরত দেয়। ফলস্বরূপ, প্রতিটি ডেটা সারি স্বয়ংক্রিয়ভাবে তার RAW_CONTACT_ID দ্বারা নতুন ContactsContract.RawContacts row এর সাথে সংযুক্ত হয় যার সাথে এটি সম্পর্কিত।
 ইমেল সারি যোগ করে এমন ContentProviderOperation.Builder অবজেক্টটি withYieldAllowed() দিয়ে ফ্ল্যাগ করা হয়, যা একটি yield পয়েন্ট সেট করে: 
কোটলিন
// Creates the display name for the new raw contact, as a StructuredName data row. op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) /* * withValueBackReference sets the value of the first argument to the value of * the ContentProviderResult indexed by the second argument. In this particular * call, the raw contact ID column of the StructuredName data row is set to the * value of the result returned by the first operation, which is the one that * actually adds the raw contact row. */ .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) // Sets the data row's MIME type to StructuredName .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) // Sets the data row's display name to the name in the UI. .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name) // Builds the operation and adds it to the array of operations ops.add(op.build()) // Inserts the specified phone number and type as a Phone data row op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) /* * Sets the value of the raw contact id column to the new raw contact ID returned * by the first operation in the batch. */ .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) // Sets the data row's MIME type to Phone .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE) // Sets the phone number and type .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, phone) .withValue(ContactsContract.CommonDataKinds.Phone.TYPE, phoneType) // Builds the operation and adds it to the array of operations ops.add(op.build()) // Inserts the specified email and type as a Phone data row op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) /* * Sets the value of the raw contact id column to the new raw contact ID returned * by the first operation in the batch. */ .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) // Sets the data row's MIME type to Email .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) // Sets the email address and type .withValue(ContactsContract.CommonDataKinds.Email.ADDRESS, email) .withValue(ContactsContract.CommonDataKinds.Email.TYPE, emailType) /* * Demonstrates a yield point. At the end of this insert, the batch operation's thread * will yield priority to other threads. Use after every set of operations that affect a * single contact, to avoid degrading performance. */ op.withYieldAllowed(true) // Builds the operation and adds it to the array of operations ops.add(op.build())
জাভা
// Creates the display name for the new raw contact, as a StructuredName data row. op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) /* * withValueBackReference sets the value of the first argument to the value of * the ContentProviderResult indexed by the second argument. In this particular * call, the raw contact ID column of the StructuredName data row is set to the * value of the result returned by the first operation, which is the one that * actually adds the raw contact row. */ .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) // Sets the data row's MIME type to StructuredName .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) // Sets the data row's display name to the name in the UI. .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name); // Builds the operation and adds it to the array of operations ops.add(op.build()); // Inserts the specified phone number and type as a Phone data row op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) /* * Sets the value of the raw contact id column to the new raw contact ID returned * by the first operation in the batch. */ .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) // Sets the data row's MIME type to Phone .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE) // Sets the phone number and type .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, phone) .withValue(ContactsContract.CommonDataKinds.Phone.TYPE, phoneType); // Builds the operation and adds it to the array of operations ops.add(op.build()); // Inserts the specified email and type as a Phone data row op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) /* * Sets the value of the raw contact id column to the new raw contact ID returned * by the first operation in the batch. */ .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) // Sets the data row's MIME type to Email .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) // Sets the email address and type .withValue(ContactsContract.CommonDataKinds.Email.ADDRESS, email) .withValue(ContactsContract.CommonDataKinds.Email.TYPE, emailType); /* * Demonstrates a yield point. At the end of this insert, the batch operation's thread * will yield priority to other threads. Use after every set of operations that affect a * single contact, to avoid degrading performance. */ op.withYieldAllowed(true); // Builds the operation and adds it to the array of operations ops.add(op.build());
 The last snippet shows the call to applyBatch() that inserts the new raw contact and data rows. 
কোটলিন
// Ask the Contacts Provider to create a new contact Log.d(TAG, "Selected account: ${mSelectedAccount.name} (${mSelectedAccount.type})") Log.d(TAG, "Creating contact: $name") /* * Applies the array of ContentProviderOperation objects in batch. The results are * discarded. */ try { contentResolver.applyBatch(ContactsContract.AUTHORITY, ops) } catch (e: Exception) { // Display a warning val txt: String = getString(R.string.contactCreationFailure) Toast.makeText(applicationContext, txt, Toast.LENGTH_SHORT).show() // Log exception Log.e(TAG, "Exception encountered while inserting contact: $e") } }
জাভা
// Ask the Contacts Provider to create a new contact Log.d(TAG,"Selected account: " + selectedAccount.getName() + " (" + selectedAccount.getType() + ")"); Log.d(TAG,"Creating contact: " + name); /* * Applies the array of ContentProviderOperation objects in batch. The results are * discarded. */ try { getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); } catch (Exception e) { // Display a warning Context ctx = getApplicationContext(); CharSequence txt = getString(R.string.contactCreationFailure); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(ctx, txt, duration); toast.show(); // Log exception Log.e(TAG, "Exception encountered while inserting contact: " + e); } }
Batch operations also allow you to implement optimistic concurrency control , a method of applying modification transactions without having to lock the underlying repository. To use this method, you apply the transaction and then check for other modifications that may have been made at the same time. If you find an inconsistent modification has occurred, you roll back your transaction and retry it.
Optimistic concurrency control is useful for a mobile device, where there's only one user at a time, and simultaneous accesses to a data repository are rare. Because locking isn't used, no time is wasted on setting locks or waiting for other transactions to release their locks.
 To use optimistic concurrency control while updating a single ContactsContract.RawContacts row, follow these steps:
-  Retrieve the raw contact's 
VERSIONcolumn along with the other data you retrieve. -  Create a 
ContentProviderOperation.Builderobject suitable for enforcing a constraint, using the methodnewAssertQuery(Uri). For the content URI, useRawContacts.CONTENT_URIwith the raw contact's_IDappended to it. -  For the 
ContentProviderOperation.Builderobject, callwithValue()to compare theVERSIONcolumn to the version number you just retrieved. -  For the same 
ContentProviderOperation.Builder, callwithExpectedCount()to ensure that only one row is tested by this assertion. -  Call 
build()to create theContentProviderOperationobject, then add this object as the first object in theArrayListthat you pass toapplyBatch(). - Apply the batch transaction.
 
 If the raw contact row is updated by another operation between the time you read the row and the time you attempt to modify it, the "assert" ContentProviderOperation will fail, and the entire batch of operations will be backed out. You can then choose to retry the batch or take some other action.
 The following snippet demonstrates how to create an "assert" ContentProviderOperation after querying for a single raw contact using a CursorLoader : 
কোটলিন
/* * The application uses CursorLoader to query the raw contacts table. The system calls this method * when the load is finished. */ override fun onLoadFinished(loader: Loader<Cursor>, cursor: Cursor) { // Gets the raw contact's _ID and VERSION values rawContactID = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)) mVersion = cursor.getInt(cursor.getColumnIndex(SyncColumns.VERSION)) } ... // Sets up a Uri for the assert operation val rawContactUri: Uri = ContentUris.withAppendedId( ContactsContract.RawContacts.CONTENT_URI, rawContactID ) // Creates a builder for the assert operation val assertOp: ContentProviderOperation.Builder = ContentProviderOperation.newAssertQuery(rawContactUri).apply { // Adds the assertions to the assert operation: checks the version withValue(SyncColumns.VERSION, mVersion) // and count of rows tested withExpectedCount(1) } // Creates an ArrayList to hold the ContentProviderOperation objects val ops = arrayListOf<ContentProviderOperation>() ops.add(assertOp.build()) // You would add the rest of your batch operations to "ops" here ... // Applies the batch. If the assert fails, an Exception is thrown try { val results: Array<ContentProviderResult> = contentResolver.applyBatch(AUTHORITY, ops) } catch (e: OperationApplicationException) { // Actions you want to take if the assert operation fails go here }
জাভা
/* * The application uses CursorLoader to query the raw contacts table. The system calls this method * when the load is finished. */ public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { // Gets the raw contact's _ID and VERSION values rawContactID = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)); mVersion = cursor.getInt(cursor.getColumnIndex(SyncColumns.VERSION)); } ... // Sets up a Uri for the assert operation Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactID); // Creates a builder for the assert operation ContentProviderOperation.Builder assertOp = ContentProviderOperation.newAssertQuery(rawContactUri); // Adds the assertions to the assert operation: checks the version and count of rows tested assertOp.withValue(SyncColumns.VERSION, mVersion); assertOp.withExpectedCount(1); // Creates an ArrayList to hold the ContentProviderOperation objects ArrayList ops = new ArrayList<ContentProviderOperation>; ops.add(assertOp.build()); // You would add the rest of your batch operations to "ops" here ... // Applies the batch. If the assert fails, an Exception is thrown try { ContentProviderResult[] results = getContentResolver().applyBatch(AUTHORITY, ops); } catch (OperationApplicationException e) { // Actions you want to take if the assert operation fails go here }
Retrieval and modification with intents
Sending an intent to the device's contacts application allows you to access the Contacts Provider indirectly. The intent starts the device's contacts application UI, in which users can do contacts-related work. With this type of access, users can:
- Pick a contact from a list and have it returned to your app for further work.
 - Edit an existing contact's data.
 - Insert a new raw contact for any of their accounts.
 - Delete a contact or contacts data.
 
If the user is inserting or updating data, you can collect the data first and send it as part of the intent.
When you use intents to access the Contacts Provider via the device's contacts application, you don't have to write your own UI or code for accessing the provider. You also don't have to request permission to read or write to the provider. The device's contacts application can delegate read permission for a contact to you, and because you're making modifications to the provider through another application, you don't have to have write permissions.
 The general process of sending an intent to access a provider is described in detail in the Content Provider basics guide in the section "Data access via intents." The action, MIME type, and data values you use for the available tasks are summarized in Table 4, while the extras values you can use with putExtra() are listed in the reference documentation for ContactsContract.Intents.Insert :
Table 4. Contacts Provider Intents.
| কাজ | অ্যাকশন | উপাত্ত | MIME টাইপ | মন্তব্য | 
|---|---|---|---|---|
| Pick a contact from a list |  ACTION_PICK |  One of:
  | ব্যবহৃত হয়নি |  Displays a list of raw contacts or a list of data from a raw contact, depending on the content URI type you supply.  Call   | 
| Insert a new raw contact |  Insert.ACTION | নিষিদ্ধ |  RawContacts.CONTENT_TYPE , MIME type for a set of raw contacts. |  Displays the device's contacts application's Add Contact screen. The extras values you add to the intent are displayed. If sent with startActivityForResult() , the content URI of the newly-added raw contact is passed back to your activity's onActivityResult() callback method in the Intent argument, in the "data" field. To get the value, call getData() . | 
| একটি পরিচিতি সম্পাদনা করুন |  ACTION_EDIT |  CONTENT_LOOKUP_URI for the contact. The editor activity will allow the user to edit any of the data associated with this contact. |  Contacts.CONTENT_ITEM_TYPE , a single contact. | Displays the Edit Contact screen in the contacts application. The extras values you add to the intent are displayed. When the user clicks Done to save the edits, your activity returns to the foreground. | 
| Display a picker that can also add data. |  ACTION_INSERT_OR_EDIT | নিষিদ্ধ |  CONTENT_ITEM_TYPE |  This intent always displays the contacts app's picker screen. The user can either pick a contact to edit, or add a new contact. Either the edit or the add screen appears, depending on the user's choice, and the extras data you pass in the intent is displayed. If your app displays contact data such as an email or phone number, use this intent to allow the user to add the data to an existing contact. contact, Note: There's no need to send a name value in this intent's extras, because the user always picks an existing name or adds a new one. Moreover, if you send a name, and the user chooses to do an edit, the contacts app will display the name you send, overwriting the previous value. If the user doesn't notice this and saves the edit, the old value is lost.  | 
 The device's contacts app doesn't allow you to delete a raw contact or any of its data with an intent. Instead, to delete a raw contact, use ContentResolver.delete() or ContentProviderOperation.newDelete() .
The following snippet shows how to construct and send an intent that inserts a new raw contact and data:
কোটলিন
// Gets values from the UI val name = contactNameEditText.text.toString() val phone = contactPhoneEditText.text.toString() val email = contactEmailEditText.text.toString() val company = companyName.text.toString() val jobtitle = jobTitle.text.toString() /* * Demonstrates adding data rows as an array list associated with the DATA key */ // Defines an array list to contain the ContentValues objects for each row val contactData = arrayListOf<ContentValues>() /* * Defines the raw contact row */ // Sets up the row as a ContentValues object val rawContactRow = ContentValues().apply { // Adds the account type and name to the row put(ContactsContract.RawContacts.ACCOUNT_TYPE, selectedAccount.type) put(ContactsContract.RawContacts.ACCOUNT_NAME, selectedAccount.name) } // Adds the row to the array contactData.add(rawContactRow) /* * Sets up the phone number data row */ // Sets up the row as a ContentValues object val phoneRow = ContentValues().apply { // Specifies the MIME type for this data row (all data rows must be marked by their type) put(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE) // Adds the phone number and its type to the row put(ContactsContract.CommonDataKinds.Phone.NUMBER, phone) } // Adds the row to the array contactData.add(phoneRow) /* * Sets up the email data row */ // Sets up the row as a ContentValues object val emailRow = ContentValues().apply { // Specifies the MIME type for this data row (all data rows must be marked by their type) put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) // Adds the email address and its type to the row put(ContactsContract.CommonDataKinds.Email.ADDRESS, email) } // Adds the row to the array contactData.add(emailRow) // Creates a new intent for sending to the device's contacts application val insertIntent = Intent(ContactsContract.Intents.Insert.ACTION).apply { // Sets the MIME type to the one expected by the insertion activity type = ContactsContract.RawContacts.CONTENT_TYPE // Sets the new contact name putExtra(ContactsContract.Intents.Insert.NAME, name) // Sets the new company and job title putExtra(ContactsContract.Intents.Insert.COMPANY, company) putExtra(ContactsContract.Intents.Insert.JOB_TITLE, jobtitle) /* * Adds the array to the intent's extras. It must be a parcelable object in order to * travel between processes. The device's contacts app expects its key to be * Intents.Insert.DATA */ putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, contactData) } // Send out the intent to start the device's contacts app in its add contact activity. startActivity(insertIntent)
জাভা
// Gets values from the UI String name = contactNameEditText.getText().toString(); String phone = contactPhoneEditText.getText().toString(); String email = contactEmailEditText.getText().toString(); String company = companyName.getText().toString(); String jobtitle = jobTitle.getText().toString(); // Creates a new intent for sending to the device's contacts application Intent insertIntent = new Intent(ContactsContract.Intents.Insert.ACTION); // Sets the MIME type to the one expected by the insertion activity insertIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE); // Sets the new contact name insertIntent.putExtra(ContactsContract.Intents.Insert.NAME, name); // Sets the new company and job title insertIntent.putExtra(ContactsContract.Intents.Insert.COMPANY, company); insertIntent.putExtra(ContactsContract.Intents.Insert.JOB_TITLE, jobtitle); /* * Demonstrates adding data rows as an array list associated with the DATA key */ // Defines an array list to contain the ContentValues objects for each row ArrayList<ContentValues> contactData = new ArrayList<ContentValues>(); /* * Defines the raw contact row */ // Sets up the row as a ContentValues object ContentValues rawContactRow = new ContentValues(); // Adds the account type and name to the row rawContactRow.put(ContactsContract.RawContacts.ACCOUNT_TYPE, selectedAccount.getType()); rawContactRow.put(ContactsContract.RawContacts.ACCOUNT_NAME, selectedAccount.getName()); // Adds the row to the array contactData.add(rawContactRow); /* * Sets up the phone number data row */ // Sets up the row as a ContentValues object ContentValues phoneRow = new ContentValues(); // Specifies the MIME type for this data row (all data rows must be marked by their type) phoneRow.put( ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE ); // Adds the phone number and its type to the row phoneRow.put(ContactsContract.CommonDataKinds.Phone.NUMBER, phone); // Adds the row to the array contactData.add(phoneRow); /* * Sets up the email data row */ // Sets up the row as a ContentValues object ContentValues emailRow = new ContentValues(); // Specifies the MIME type for this data row (all data rows must be marked by their type) emailRow.put( ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE ); // Adds the email address and its type to the row emailRow.put(ContactsContract.CommonDataKinds.Email.ADDRESS, email); // Adds the row to the array contactData.add(emailRow); /* * Adds the array to the intent's extras. It must be a parcelable object in order to * travel between processes. The device's contacts app expects its key to be * Intents.Insert.DATA */ insertIntent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, contactData); // Send out the intent to start the device's contacts app in its add contact activity. startActivity(insertIntent);
তথ্য অখণ্ডতা
Because the contacts repository contains important and sensitive data that users expect to be correct and up-to-date, the Contacts Provider has well-defined rules for data integrity. It's your responsibility to conform to these rules when you modify contacts data. The important rules are listed here:
-  Always add a 
ContactsContract.CommonDataKinds.StructuredNamerow for everyContactsContract.RawContactsrow you add. -  A 
ContactsContract.RawContactsrow without aContactsContract.CommonDataKinds.StructuredNamerow in theContactsContract.Datatable may cause problems during aggregation. -  Always link new 
ContactsContract.Datarows to their parentContactsContract.RawContactsrow. -  A 
ContactsContract.Datarow that isn't linked to aContactsContract.RawContactswon't be visible in the device's contacts application, and it might cause problems with sync adapters. - Change data only for those raw contacts that you own.
 - Remember that the Contacts Provider is usually managing data from several different account types/online services. You need to ensure that your application only modifies or deletes data for rows that belong to you, and that it only inserts data with an account type and name that you control.
 -  Always use the constants defined in 
ContactsContractand its subclasses for authorities, content URIs, URI paths, column names, MIME types, andTYPEvalues. - Using these constants helps you to avoid errors. You'll also be notified with compiler warnings if any of the constants is deprecated.
 
Custom data rows
 By creating and using your own custom MIME types, you can insert, edit, delete, and retrieve your own data rows in the ContactsContract.Data table. Your rows are limited to using the column defined in ContactsContract.DataColumns , although you can map your own type-specific column names to the default column names. In the device's contacts application, the data for your rows is displayed but can't be edited or deleted, and users can't add additional data. To allow users to modify your custom data rows, you must provide an editor activity in your own application.
 To display your custom data, provide a contacts.xml file containing a <ContactsAccountType> element and one or more of its <ContactsDataKind> child elements. This is described in more detail in the section <ContactsDataKind> element .
To learn more about custom MIME types, read the Create a Content Provider guide.
Contacts Provider sync adapters
The Contacts Provider is specifically designed for handling synchronization of contacts data between a device and an online service. This allows users to download existing data to a new device and upload existing data to a new account. Synchronization also ensures that users have the latest data at hand, regardless of the source of additions and changes. Another advantage of synchronization is that it makes contacts data available even when the device is not connected to the network.
Although you can implement synchronization in a variety of ways, the Android system provides a plug-in synchronization framework that automates the following tasks:
- Checking network availability.
 - Scheduling and executing synchronization, based on user preferences.
 - Restarting synchronizations that have stopped.
 
To use this framework, you supply a sync adapter plug-in. Each sync adapter is unique to a service and content provider, but can handle multiple account names for the same service. The framework also allows multiple sync adapters for the same service and provider.
Sync adapter classes and files
 You implement a sync adapter as a subclass of AbstractThreadedSyncAdapter and install it as part of an Android application. The system learns about the sync adapter from elements in your application manifest, and from a special XML file pointed to by the manifest. The XML file defines the account type for the online service and the authority for the content provider, which together uniquely identify the adapter. The sync adapter does not become active until the user adds an account for the sync adapter's account type and enables synchronization for the content provider the sync adapter syncs with. At that point, the system starts managing the adapter, calling it as necessary to synchronize between the content provider and the server.
 Note: Using an account type as part of the sync adapter's identification allows the system to detect and group together sync adapters that access different services from the same organization. For example, sync adapters for Google online services all have the same account type com.google . When users add a Google Account to their devices, all of the installed sync adapters for Google services are listed together; each sync adapter listed syncs with a different content provider on the device.
 Because most services require users to verify their identity before accessing data, the Android system offers an authentication framework that is similar to, and often used in conjunction with, the sync adapter framework. The authentication framework uses plug-in authenticators that are subclasses of AbstractAccountAuthenticator . An authenticator verifies the user's identity in the following steps:
- Collects the user's name, password or similar information (the user's credentials ).
 - Sends the credentials to the service
 - Examines the service's reply.
 
 If the service accepts the credentials, the authenticator can store the credentials for later use. Because of the plug-in authenticator framework, the AccountManager can provide access to any authtokens an authenticator supports and chooses to expose, such as OAuth2 authtokens.
Although authentication is not required, most contacts services use it. However, you're not required to use the Android authentication framework to do authentication.
Sync adapter implementation
To implement a sync adapter for the Contacts Provider, you start by creating an Android application that contains the following:
-  A 
Servicecomponent that responds to requests from the system to bind to the sync adapter. -  When the system wants to run a synchronization, it calls the service's 
onBind()method to get anIBinderfor the sync adapter. This allows the system to do cross-process calls to the adapter's methods. -  The actual sync adapter, implemented as a concrete subclass of 
AbstractThreadedSyncAdapter. -  This class does the work of downloading data from the server, uploading data from the device, and resolving conflicts. The main work of the adapter is done in the method 
onPerformSync(). This class must be instantiated as a singleton. -  A subclass of 
Application. -  This class acts as a factory for the sync adapter singleton. Use the 
onCreate()method to instantiate the sync adapter, and provide a static "getter" method to return the singleton to theonBind()method of the sync adapter's service. -  Optional: A 
Servicecomponent that responds to requests from the system for user authentication. -  
AccountManagerstarts this service to begin the authentication process. The service'sonCreate()method instantiates an authenticator object. When the system wants to authenticate a user account for the application's sync adapter, it calls the service'sonBind()method to get anIBinderfor the authenticator. This allows the system to do cross-process calls to the authenticator's methods.. -  Optional: A concrete subclass of 
AbstractAccountAuthenticatorthat handles requests for authentication. -  This class provides methods that the 
AccountManagerinvokes to authenticate the user's credentials with the server. The details of the authentication process vary widely, based on the server technology in use. You should refer to the documentation for your server software to learn more about authentication. - XML files that define the sync adapter and authenticator to the system.
 -  The sync adapter and authenticator service components described previously are defined in 
< service >elements in the application manifest. These elements contain< meta-data >child elements that provide specific data to the system:-  The 
< meta-data >element for the sync adapter service points to the XML fileres/xml/syncadapter.xml. In turn, this file specifies a URI for the web service that will be synchronized with the Contacts Provider, and an account type for the web service. -  Optional: The 
< meta-data >element for the authenticator points to the XML fileres/xml/authenticator.xml. In turn, this file specifies the account type that this authenticator supports, as well as UI resources that appear during the authentication process. The account type specified in this element must be the same as the account type specified for the sync adapter. 
 -  The 
 
Social stream data
The android.provider.ContactsContract.StreamItems and android.provider.ContactsContract.StreamItemPhotos tables manage incoming data from social networks. You can write a sync adapter that adds stream data from your own network to these tables, or you can read stream data from these tables and display it in your own application, or both. With these features, your social networking services and applications can be integrated into Android's social networking experience.
Social stream text
 Stream items are always associated with a raw contact. The android.provider.ContactsContract.StreamItemsColumns#RAW_CONTACT_ID links to the _ID value for the raw contact. The account type and account name of the raw contact are also stored in the stream item row.
Store the data from your stream in the following columns:
- android.provider.ContactsContract.StreamItemsColumns#ACCOUNT_TYPE
 - Required. The user's account type for the raw contact associated with this stream item. Remember to set this value when you insert a stream item.
 - android.provider.ContactsContract.StreamItemsColumns#ACCOUNT_NAME
 - Required. The user's account name for the raw contact associated with this stream item. Remember to set this value when you insert a stream item.
 - Identifier columns
 -  Required. You must insert the following identifier columns when you insert a stream item:
- android.provider.ContactsContract.StreamItemsColumns#CONTACT_ID: The android.provider.BaseColumns#_ID value of the contact that this stream item is associated with.
 - android.provider.ContactsContract.StreamItemsColumns#CONTACT_LOOKUP_KEY: The android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY value of the contact this stream item is associated with.
 - android.provider.ContactsContract.StreamItemsColumns#RAW_CONTACT_ID: The android.provider.BaseColumns#_ID value of the raw contact that this stream item is associated with.
 
 - android.provider.ContactsContract.StreamItemsColumns#COMMENTS
 - Optional. Stores summary information that you can display at the beginning of a stream item.
 - android.provider.ContactsContract.StreamItemsColumns#TEXT
 -  The text of the stream item, either the content that was posted by the source of the item, or a description of some action that generated the stream item. This column can contain any formatting and embedded resource images that can be rendered by 
fromHtml(). The provider may truncate or ellipsize long content, but it will try to avoid breaking tags. - android.provider.ContactsContract.StreamItemsColumns#TIMESTAMP
 - A text string containing the time the stream item was inserted or updated, in the form of milliseconds since epoch. Applications that insert or update stream items are responsible for maintaining this column; it is not automatically maintained by the Contacts Provider.
 
To display identifying information for your stream items, use the android.provider.ContactsContract.StreamItemsColumns#RES_ICON, android.provider.ContactsContract.StreamItemsColumns#RES_LABEL, and android.provider.ContactsContract.StreamItemsColumns#RES_PACKAGE to link to resources in your application.
The android.provider.ContactsContract.StreamItems table also contains the columns android.provider.ContactsContract.StreamItemsColumns#SYNC1 through android.provider.ContactsContract.StreamItemsColumns#SYNC4 for the exclusive use of sync adapters.
Social stream photos
 The android.provider.ContactsContract.StreamItemPhotos table stores photos associated with a stream item. The table's android.provider.ContactsContract.StreamItemPhotosColumns#STREAM_ITEM_ID column links to values in the _ID column of android.provider.ContactsContract.StreamItems table. Photo references are stored in the table in these columns:
- android.provider.ContactsContract.StreamItemPhotos#PHOTO column (a BLOB).
 - A binary representation of the photo, resized by the provider for storage and display. This column is available for backwards compatibility with previous versions of the Contacts Provider that used it for storing photos. However, in the current version you should not use this column to store photos. Instead, use either android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_FILE_ID or android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_URI (both of which are described in the following points) to store photos in a file. This column now contains a thumbnail of the photo, which is available for reading.
 - android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_FILE_ID
 -  A numeric identifier of a photo for a raw contact. Append this value to the constant 
DisplayPhoto.CONTENT_URIto get a content URI pointing to a single photo file, and then callopenAssetFileDescriptor()to get a handle to the photo file. - android.provider.ContactsContract.StreamItemPhotosColumns#PHOTO_URI
 -  A content URI pointing directly to the photo file for the photo represented by this row. Call 
openAssetFileDescriptor()with this URI to get a handle to the photo file. 
Using the social stream tables
These tables work the same as the other main tables in the Contacts Provider, except that:
- These tables require additional access permissions. To read from them, your application must have the permission android.Manifest.permission#READ_SOCIAL_STREAM. To modify them, your application must have the permission android.Manifest.permission#WRITE_SOCIAL_STREAM.
 -  For the android.provider.ContactsContract.StreamItems table, the number of rows stored for each raw contact is limited. Once this limit is reached, the Contacts Provider makes space for new stream item rows by automatically deleting the rows having the oldest android.provider.ContactsContract.StreamItemsColumns#TIMESTAMP. To get the limit, issue a query to the content URI android.provider.ContactsContract.StreamItems#CONTENT_LIMIT_URI. You can leave all the arguments other than the content URI set to 
null. The query returns a Cursor containing a single row, with the single column android.provider.ContactsContract.StreamItems#MAX_ITEMS. 
The class android.provider.ContactsContract.StreamItems.StreamItemPhotos defines a sub-table of android.provider.ContactsContract.StreamItemPhotos containing the photo rows for a single stream item.
Social stream interactions
The social stream data managed by the Contacts Provider, in conjunction with the device's contacts application, offers a powerful way to connect your social networking system with existing contacts. The following features are available:
- By syncing your social networking service to the Contacts Provider with a sync adapter, you can retrieve recent activity for a user's contacts and store it in the android.provider.ContactsContract.StreamItems and android.provider.ContactsContract.StreamItemPhotos tables for later use.
 - Besides regular synchronization, you can trigger your sync adapter to retrieve additional data when the user selects a contact to view. This allows your sync adapter to retrieve high-resolution photos and the most recent stream items for the contact.
 - By registering a notification with the device's contacts application and the Contacts Provider, you can receive an intent when a contact is viewed, and at that point update the contact's status from your service. This approach may be faster and use less bandwidth than doing a full sync with a sync adapter.
 - Users can add a contact to your social networking service while looking at the contact in the device's contacts application. You enable this with the "invite contact" feature, which you enable with a combination of an activity that adds an existing contact to your network, and an XML file that provides the device's contacts application and the Contacts Provider with the details of your application.
 
Regular synchronization of stream items with the Contacts Provider is the same as other synchronizations. To learn more about synchronization, see the section Contacts Provider sync adapters . Registering notifications and inviting contacts are covered in the next two sections.
Registering to handle social networking views
To register your sync adapter to receive notifications when the user views a contact that's managed by your sync adapter:
-  Create a file named 
contacts.xmlin your project'sres/xml/directory. If you already have this file, you can skip this step. -  In this file, add the element 
<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android">. If this element already exists, you can skip this step. -  To register a service that is notified when the user opens a contact's detail page in the device's contacts application, add the attribute 
viewContactNotifyService=" serviceclass "to the element, whereserviceclassis the fully-qualified classname of the service that should receive the intent from the device's contacts application. For the notifier service, use a class that extendsIntentService, to allow the service to receive intents. The data in the incoming intent contains the content URI of the raw contact the user clicked. From the notifier service, you can bind to and then call your sync adapter to update the data for the raw contact. 
To register an activity to be called when the user clicks on a stream item or photo or both:
-  Create a file named 
contacts.xmlin your project'sres/xml/directory. If you already have this file, you can skip this step. -  In this file, add the element 
<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android">. If this element already exists, you can skip this step. -  To register one of your activities to handle the user clicking on a stream item in the device's contacts application, add the attribute 
viewStreamItemActivity=" activityclass "to the element, whereactivityclassis the fully-qualified classname of the activity that should receive the intent from the device's contacts application. -  To register one of your activities to handle the user clicking on a stream photo in the device's contacts application, add the attribute 
viewStreamItemPhotoActivity=" activityclass "to the element, whereactivityclassis the fully-qualified classname of the activity that should receive the intent from the device's contacts application. 
 The <ContactsAccountType> element is described in more detail in the section <ContactsAccountType> element .
The incoming intent contains the content URI of the item or photo that the user clicked. To have separate activities for text items and for photos, use both attributes in the same file.
Interacting with your social networking service
Users don't have to leave the device's contacts application to invite a contact to your social networking site. Instead, you can have the device's contacts app send an intent for inviting the contact to one of your activities. To set this up:
-  Create a file named 
contacts.xmlin your project'sres/xml/directory. If you already have this file, you can skip this step. -  In this file, add the element 
<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android">. If this element already exists, you can skip this step. -  Add the following attributes:
-  
inviteContactActivity=" activityclass " -  
inviteContactActionLabel="@string/ invite_action_label " 
activityclassvalue is the fully-qualified classname of the activity that should receive the intent. Theinvite_action_labelvalue is a text string that's displayed in the Add Connection menu in the device's contacts application. -  
 
 Note: ContactsSource is a deprecated tag name for ContactsAccountType .
contacts.xml reference
 The file contacts.xml contains XML elements that control the interaction of your sync adapter and application with the contacts application and the Contacts Provider. These elements are described in the following sections.
<ContactsAccountType> element
 The <ContactsAccountType> element controls the interaction of your application with the contacts application. It has the following syntax: 
<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android" inviteContactActivity="activity_name" inviteContactActionLabel="invite_command_text" viewContactNotifyService="view_notify_service" viewGroupActivity="group_view_activity" viewGroupActionLabel="group_action_text" viewStreamItemActivity="viewstream_activity_name" viewStreamItemPhotoActivity="viewphotostream_activity_name">
contained in:
 res/xml/contacts.xml
can contain:
 <ContactsDataKind>
বর্ণনা:
Declares Android components and UI labels that allow users to invite one of their contacts to a social network, notify users when one of their social networking streams is updated, and so forth.
 Notice that the attribute prefix android: is not necessary for the attributes of <ContactsAccountType> .
বৈশিষ্ট্য:
-  
inviteContactActivity - The fully-qualified class name of the activity in your application that you want to activate when the user selects Add connection from the device's contacts application.
 -  
inviteContactActionLabel -  A text string that is displayed for the activity specified in 
inviteContactActivity, in the Add connection menu. For example, you can use the string "Follow in my network". You can use a string resource identifier for this label. -  
viewContactNotifyService - The fully-qualified class name of a service in your application that should receive notifications when the user views a contact. This notification is sent by the device's contacts application; it allows your application to postpone data-intensive operations until they're needed. For example, your application can respond to this notification by reading in and displaying the contact's high-resolution photo and most recent social stream items. This feature is described in more detail in the section Social stream interactions .
 -  
viewGroupActivity - The fully-qualified class name of an activity in your application that can display group information. When the user clicks the group label in the device's contacts application, the UI for this activity is displayed.
 -  
viewGroupActionLabel -  The label that the contacts application displays for a UI control that allows the user to look at groups in your application.
A string resource identifier is allowed for this attribute.
 -  
viewStreamItemActivity - The fully-qualified class name of an activity in your application that the device's contacts application launches when the user clicks a stream item for a raw contact.
 -  
viewStreamItemPhotoActivity - The fully-qualified class name of an activity in your application that the device's contacts application launches when the user clicks a photo in the stream item for a raw contact.
 
<ContactsDataKind> element
 The <ContactsDataKind> element controls the display of your application's custom data rows in the contacts application's UI. It has the following syntax: 
<ContactsDataKind android:mimeType="MIMEtype" android:icon="icon_resources" android:summaryColumn="column_name" android:detailColumn="column_name">
contained in:
<ContactsAccountType>বর্ণনা:
 Use this element to have the contacts application display the contents of a custom data row as part of the details of a raw contact. Each <ContactsDataKind> child element of <ContactsAccountType> represents a type of custom data row that your sync adapter adds to the ContactsContract.Data table. Add one <ContactsDataKind> element for each custom MIME type you use. You don't have to add the element if you have a custom data row for which you don't want to display data.
বৈশিষ্ট্য:
-  
android:mimeType -  The custom MIME type you've defined for one of your custom data row types in the 
ContactsContract.Datatable. For example, the valuevnd.android.cursor.item/vnd.example.locationstatuscould be a custom MIME type for a data row that records a contact's last known location. -  
android:icon - An Android drawable resource that the contacts application displays next to your data. Use this to indicate to the user that the data comes from your service.
 -  
android:summaryColumn - The column name for the first of two values retrieved from the data row. The value is displayed as the first line of the entry for this data row. The first line is intended to be used as a summary of the data, but that is optional. See also android:detailColumn .
 -  
android:detailColumn -  The column name for the second of two values retrieved from the data row. The value is displayed as the second line of the entry for this data row. See also 
android:summaryColumn. 
Additional Contacts Provider features
Besides the main features described in previous sections, the Contacts Provider offers these useful features for working with contacts data:
- Contact groups
 - Photo features
 
Contact groups
 The Contacts Provider can optionally label collections of related contacts with group data. If the server associated with a user account wants to maintain groups, the sync adapter for the account's account type should transfer groups data between the Contacts Provider and the server. When users add a new contact to the server and then put this contact in a new group, the sync adapter must add the new group to the ContactsContract.Groups table. The group or groups a raw contact belongs to are stored in the ContactsContract.Data table, using the ContactsContract.CommonDataKinds.GroupMembership MIME type.
 If you're designing a sync adapter that will add raw contact data from server to the Contacts Provider, and you aren't using groups, then you need to tell the Provider to make your data visible. In the code that is executed when a user adds an account to the device, update the ContactsContract.Settings row that the Contacts Provider adds for the account. In this row, set the value of the Settings.UNGROUPED_VISIBLE column to 1. When you do this, the Contacts Provider will always make your contacts data visible, even if you don't use groups.
Contact photos
 The ContactsContract.Data table stores photos as rows with MIME type Photo.CONTENT_ITEM_TYPE . The row's CONTACT_ID column is linked to the _ID column of the raw contact to which it belongs. The class ContactsContract.Contacts.Photo defines a sub-table of ContactsContract.Contacts containing photo information for a contact's primary photo, which is the primary photo of the contact's primary raw contact. Similarly, the class ContactsContract.RawContacts.DisplayPhoto defines a sub-table of ContactsContract.RawContacts containing photo information for a raw contact's primary photo.
 The reference documentation for ContactsContract.Contacts.Photo and ContactsContract.RawContacts.DisplayPhoto contain examples of retrieving photo information. There is no convenience class for retrieving the primary thumbnail for a raw contact, but you can send a query to the ContactsContract.Data table, selecting on the raw contact's _ID , the Photo.CONTENT_ITEM_TYPE , and the IS_PRIMARY column to find the raw contact's primary photo row.
Social stream data for a person may also include photos. These are stored in the android.provider.ContactsContract.StreamItemPhotos table, which is described in more detail in the section Social stream photos .