AndroidContacts icon indicating copy to clipboard operation
AndroidContacts copied to clipboard

Just two questions

Open Lurgainn opened this issue 5 years ago • 5 comments

(1) When I get all contacts with:

List<ContactData> all_contacts  = new ContactsGetterBuilder(this)
    .allFields()
    .buildList();

the deleted contacts are included or (I hope) excluded? Because I can't see any field to check if deleted.

(2) When I create and save a new contact in an empty database with:

ContactData data = ContactDataFactory.createEmpty();
// Add some data and the Group
int id =new ContactsSaverBuilder(context)
    .saveContact(data);

what happens since the Group it not exists into the database table? The library is able to first create the Group and then the contact?

Thanks very much for your help and for this wonderful library.

Lurgainn avatar Apr 20 '19 14:04 Lurgainn

@Lurgainn as soon as contact is deleted it is no more available to be restored(i may be wrong, but i have not found any possibilities to get them), so there is no way to get them(this functionality is covered with tests, so if there were some deleted contacts got with ContactGetter - tests would fail) About the second one, pretty nice questions, it looks like i have not implemented it yet, please wait for updates until tomorrow, feel free to ping me, if I forget about this one. All other fields are created every time, you are saving them, but they are not pretending to be shared(websites, phones, addresses), but groups should be unique, will investigate it today,

blainepwnz avatar Apr 20 '19 20:04 blainepwnz

Thanks again for your quick replay!! Really!!! About (1), I'm happy that deleted contacts are ... deleted :-D. I asked because if you open the database with sqlite3, you can view the deleted raw contacts too (like deleted Groups, and every other deleted data), so I was worried that my extraction into "all_contacts" could get them. Instead I only want the active contacts, so I'm very happy with your answer! About(2), .... what can I say: THANKS VERY MUCH if you can update again this library. I asked because in my contacts I heavily used Groups, Photos, ecc., so the optimal solution it will be something that can create every accessory field (like the Groups) when I insert them into a ContactData for ContactsSaverBuilder.

Lurgainn avatar Apr 20 '19 22:04 Lurgainn

@Lurgainn i need to write another DAO for groups since they are not really connected to contacts and you need to control all flow by yourself. I mean you will have opportunity to create groups and attach groups to specific contact(manage their contens and synchronize them according to your logic). Can't give you any promises, when it will be done, but i am working on it.

blainepwnz avatar Apr 21 '19 21:04 blainepwnz

Thank you very much! I don't want to annoy you too much with my questions, but I have other three. I told you that i would use your library to create an app that backup and restore locally and offline all contacts. I almost completed the backup section so my questions are: (3) In your readme I have not completely understood the filters, so what can I do (for example) to get all the contacts that are relate to only two accounts? (4) When I extract all contacts with ContactsGetterBuilder, I get all specific database fields too, like 'contactId', 'labelId', 'groupId', 'lookupKey' ecc. Then I serialize all to json using the GSON library. I have not already looked into the ContactDataFactory for the restore section, but I think that I can't use these fields because android will recreate them while saving as new contacts. Is it correct, how I suppose? And if yes, how can I exclude these fields from the extraction, so I can deserialize the json file directly into ContactsSaverBuilder? (5) The last problem is about the photo. I saw that the extraction give me the 'uriString' and not a bitmap, so there's a way to get the actual bitmap/file? Thanks again

Lurgainn avatar Apr 26 '19 17:04 Lurgainn

@Lurgainn hey there, sorry for such long answer from my side. About first one, filters are implemented, but implemented pretty bad(i would like to reimplement them in future), much more convenient way is to filter them yourself, than to use built-in solution. About second one, after you opened this issue i have realized that contact update is very problematic to implement because of data collision(need to handle all data that is inserted or updated) About third one, you can create bitmap from uri

blainepwnz avatar May 17 '19 11:05 blainepwnz