function TCalendarEventsManager.IsAppCalendarExist: integer;
var
wValues : TJavaObjectArray<JString>;
wArgs : TJavaObjectArray<JString>;
wCursor : JCursor;
wFilter : JString;
begin
Result := -1;
try
wValues := TJavaObjectArray<JString>.Create(2); //Extracting only calendar name
wValues[0] := StringToJString('_id');
wValues[1] := StringToJString('account_name');
wFilter := StringToJString('account_type = ? AND account_name = ?'); //filter
wArgs := TJavaObjectArray<JString>.Create(2); // Arguments to filter calendars list
wArgs[0] := StringToJString('LOCAL');
wArgs[1] := StringToJString(_App_Calendar_Name);
wCursor := fContentResolver.query(StrToJURI('content://com.android.calendar/calendars'),wValues,wfilter,wArgs,nil);
if wCursor.moveToFirst then
Result := wCursor.getLong(0);
except
On E:Exception do
Raise Exception.create('[TCalendarEventsManager.IfAppCalendarExist] : '+E.message);
end;
end;
Download the Calendar Event Manager demo for Delphi XE6 Firemonkey.