Repository navigation
|
Hi everyone, Now, my problem. I would like to load only Contacts modified after a specific timestamp. Unfortunately, the I think I can check the Thanks! |
Replies: 2 comments 1 reply
|
Hi @M00r14rty, this is a good question!
As you pointed out in your question, I believe you are already doing something like this, fun loadContactsModifiedAfter(timestampMillis: Long): List<Contact> = Contacts(this)
.query()
.where { Contact.LastUpdatedTimestamp greaterThan timestampMillis }
.find()This is technically the answer to your question. But I can see it's not working the way you want it to, so let's dig a little deeper 🙂
Thanks! ❤️❤️❤️❤️❤️❤️
The If the official documentation is correct, and from my observations, this timestamp should only be updated when any one of the following events occur;
Any of the above events could occur when a sync is performed. It could be due to the Contacts Provider performing some aggregation or 3rd party apps' SyncAdapters writing to the RawContacts or Data table rows. Unfortunately, we have no control over this.
I think this is a good callout! If you look at the code in
These rows should be unaffected "after any interaction with the contact". However, they may be "updated every sync". Both of these are also just integers that start at 0 or 1. They are not timestamps, so you cannot use these to "load only Contacts modified after a specific timestamp". Though, I suppose that you can save the
These fields are currently not in the library. We would have to add them in the code first. However, I don't think these will solve your problem.
We could add custom data that we can put a timestamp into. Then, in your app, you can set the timestamp whenever your app "modifies" any data belonging to a RawContact or just whenever you want to set the timestamp. This timestamp will be unaffected by the Contacts Provider's "sync" or "interaction with the contact". There are two limitations with this approach;
If you are okay with these limitations, then please create an issue. I might call the module Let me know! Other considerationsIf you search for "time" in the Also, please let me know if the builtin AOSP Contacts app or the Google Contacts app has features that allow you to do exactly what you want to do (and how you want it to behave). This will give us a hint if it is truly something we can do with the Contacts Provider. I can guarantee you that this library will support any and all features in the AOSP Contacts app or the Google Contacts app and more. FYII changed the title of this discussion to "How to load only Contacts modified after a specific timestamp?" because it is the underlying question. Unfortunately, I don't think |
|
Thank you @vestrel00 for your exhaustive answer. As you pointed out, I already tried to use the where clause in the query. Unfortunately, I didn't find any useful field in the AOSP Contacts, that's why I decided to test a different approach. My idea is to abandone the timestamp and retrieve the versions of all contact rows to store them as unique hash value. |

Hi @M00r14rty, this is a good question!
As you pointed out in your question, I believe you are already doing something like this,
This is technically the answer to your question. But I can see it's not working the way you want it to, so let's dig a little deeper 🙂
Thanks! ❤️❤️❤️❤️❤️❤️
The
Fields.Contact.LastUpdatedTimestampshould be what you need to use.…