本文介绍了在日历中添加提醒时android.database.sqlite.SQLiteException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 @SuppressLint({"RxLeakedSubscription", "RxSubscribeOnError"})
public static long pushAppointmentsToCalender(Activity curActivity, String title, String addInfo, String place, int status, long startDate, boolean needReminder) {
    /***************** Event: note(without alert) *******************/

    ContentResolver cr = curActivity.getContentResolver();
    ContentValues values = new ContentValues();
    values.put(CalendarContract.Events.DTSTART, startDate);
    values.put(CalendarContract.Events.DTEND, startDate);
    values.put(CalendarContract.Events.TITLE, title);
    values.put(CalendarContract.Events.DESCRIPTION, addInfo);
    values.put(CalendarContract.Events.CALENDAR_ID, startDate);
    values.put(CalendarContract.Events.EVENT_TIMEZONE, "Asia/Calcutta");
    @SuppressLint("MissingPermission") Uri uriEvent = cr.insert(CalendarContract.Events.CONTENT_URI, values);

    long eventID = Long.parseLong(uriEvent.getLastPathSegment());
    try {
        if (needReminder) {
            ContentResolver crreminder = curActivity.getContentResolver();
            ContentValues valuesreminder = new ContentValues();
            valuesreminder.put(CalendarContract.Reminders.EVENT_ID, eventID);
            valuesreminder.put(CalendarContract.Reminders.MINUTES, 15);
            valuesreminder.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
            @SuppressLint("MissingPermission") Uri uri = crreminder.insert(CalendarContract.Reminders.CONTENT_URI, valuesreminder);
        }
    }catch (Exception e){
        e.printStackTrace();
    }
    return eventID;
}

我在日志中遇到的错误是

2019-03-06 16:29:16.935 23021-23021/com.medikoe.connect.debug W/System.err: android.database.sqlite.SQLiteException
2019-03-06 16:29:16.936 23021-23021/com.medikoe.connect.debug

事件ID已成功创建,但在插入uri进行提醒时会创建sqlite异常。

Event id is created successfully but while inserting uri for reminder is creating sqlite exception . Please help!

推荐答案




  1. 如果您未在
    手机中配置Google日历应用/ emulator将发生此错误。然后,请确保在运行应用程序之前,使用gmail帐户配置Google日历应用程序。

  1. If you didn't config your google calendar app in yourphone/emulator this error will occur. Then make sure that you configure the google calendar app with a gmail account before running the app.

如果您给事件传递了格式错误或错误的时间,或者提醒。使用具有正确时区的Unix时间。

If you are passing wrong formatted or false time to the event or reminder. use unix time with correct time zone.

这篇关于在日历中添加提醒时android.database.sqlite.SQLiteException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 21:03