How to query to get the contact list which were deleted? #207
-
How to query to get the contact list which were deleted? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @heroickunal, great question! It's a tricky question to answer because there are so many different things that can be said about it. There are two ways of answering this question. Read the short answer for the TLDR. Read the long answer if you want a more detailed explanation. I will answer this as thoroughly as I can because it is actually a very good question whose answer is not very straightforward. Short answerYou cannot get contacts that have been deleted just by using the In order for you to be able to get "deleted contacts", you would have to interface with accounts that support "trash". This requires network access and authentication, both of which are not in scope of this library. Long answerFirst, we'll take a look at what other apps do with regards to deleting contacts. Second, I will explain what happens when deleting contacts using I. What other apps do with regards to deleting contactsLet's take a look at what the Google Contacts app, Samsung Contacts, and the default Android Open Source Project (AOSP) Contacts app does with deleted contacts...
When deleting a synced contact (associated with an Account; i.e. [email protected]), the Google Contacts app shows you a prompt to "Move to Trash? This contact will be removed from all your synced devices". There is one keyword here; "synced". You can read more about the documentation I wrote about "syncing contact data" in this page; https://vestrel00.github.io/contacts-android/entities/sync-contact-data/ Deleting the synced contact does remove it from the local database. However, since the synced contact is associated with a Google account, Google still has a record of the contact in their remote database. This is how the Google Contacts app is able to show deleted contacts- they download it over the network. It is also the same mechanism used for "back-up and restore" functionality. Turning off network connection by using airplane mode shows you that contacts in the Trash cannot be shown unless you have internet connection. When deleting a local, device-only contact, Google Contacts shows you a prompt to "Delete contact? This contact will be permanently deleted from your device". Notice that the messaging is different in this case. The contact will actually be deleted. It will not be accessible in the trash because it is not associated with a Google account. It is stored only locally in the device. If you look at the Samsung phones replaces the AOSP Contacts app with their own proprietary Contacts app. You can enable the trash functionality there. Unlike the Google Contacts app, the Samsung Contacts app supports deleting device-only local contacts and having it live in the trash. If you look at the The default AOSP Contacts app that comes with vanilla Android phones does not support trash functionality at all for synced and local contacts due to the limitations of the II. How deleting contacts work when using this library or the
|
Beta Was this translation helpful? Give feedback.
Hey @heroickunal, great question! It's a tricky question to answer because there are so many different things that can be said about it. There are two ways of answering this question. Read the short answer for the TLDR. Read the long answer if you want a more detailed explanation.
I will answer this as thoroughly as I can because it is actually a very good question whose answer is not very straightforward.
Short answer
You cannot get contacts that have been deleted just by using the
ContactsContract
alone. Since this library is only a wrapper aroundContactsContract
, it does not allow you to get deleted contacts because they are actually deleted from the local database tables.In order fo…