How to prevent duplicate entries?
I am beginner android developer.I am writing app witch write calls(incomming,outgoing,missed) to Android Calendar with some useful informations about call.Now i am trying to prevent from duplicate entries.For example if i run this app 2x and the calendar will be filled with duplicate entries.Has anybody got some great idea how to do it?I thought about this, i save开发者_如何学运维 date of last call witch is written to the calendar and then it will continue from this date. Sorry for my English.
I would check to see if there exists a calendar entry with the same start/end time before you write anything to the calendar. That would make sure that the same entry is never written twice, even if the app is uninstalled/reinstalled.
You have the right idea. After the program is run, save the current date (in long
form) as a SharedProperty. When you load up the application next time, grab the last run date and then ignore every missed call before that date.
One solution is to create a separate, private SQLite database that stores what you've inserted into the calendar and that utilizes SQL's unique
attribute to determine if you should insert a new item into the calendar based on whether it's already been inserted.
精彩评论