How Do I Use ContentResolver To Check If Events Exists In The Calendar Or Not?

Mathias8405

New member
Apr 25, 2018
1
0
0
I need help with this code that I've been trying to figure out for hours. I know it's something close to what I have from my research, but I can't get it to work. Not even the codes provided from other posts works for me on here. Any ideas?

public void checkEventsInCal() {
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(Uri.parse("content://com.android.calendar/events"), new String[]{"_id"}, "_id=?", new String[]{CalendarContract.Events.TITLE}, null);

if (cursor.moveToFirst()) {
Toast.makeText(this,"Event Exists!", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(this,"Event Doesn't Exist!", Toast.LENGTH_SHORT).show();
}
}
 
I moved this from the Android Apps forum to the Software Development forum, since the former is intended for developers to promote their apps.
 

Trending Posts

Forum statistics

Threads
956,393
Messages
6,967,998
Members
3,163,534
Latest member
Chauncey the Gardener