Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.database.sqlite.SQLiteException #138

Closed
zbettenbuk opened this issue Apr 23, 2018 · 5 comments
Closed

android.database.sqlite.SQLiteException #138

zbettenbuk opened this issue Apr 23, 2018 · 5 comments

Comments

@zbettenbuk
Copy link
Contributor

We receive the following exception on Android 4.1.2:

Fatal Exception: android.database.sqlite.SQLiteException: no such column: isPrimary (code 1): , while compiling: SELECT _id, calendar_displayName, account_name, isPrimary, calendar_access_level, allowedAvailability, account_type FROM Calendars WHERE (_id=?)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:184)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:425)
at android.content.ContentResolver.query(ContentResolver.java:367)
at com.calendarevents.CalendarEvents.findCalendarById(CalendarEvents.java:124)
at com.calendarevents.CalendarEvents.serializeEvent(CalendarEvents.java:857)
at com.calendarevents.CalendarEvents.serializeEvents(CalendarEvents.java:786)
at com.calendarevents.CalendarEvents.findEvents(CalendarEvents.java:215)
at com.calendarevents.CalendarEvents.access$200(CalendarEvents.java:38)
at com.calendarevents.CalendarEvents$3.run(CalendarEvents.java:1011)
at java.lang.Thread.run(Thread.java:856)

Environment

Fabric info see attached.

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.3
Yarn: Not Found
npm: 5.7.1
Watchman: Not Found
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.51.0 => 0.51.0

Steps to Reproduce

Request a calendar event list on Android 4.1.2 version devices

Expected Behavior

Get a list of events

Actual Behavior

Native crash, see above

image

@wmcmahan
Copy link
Owner

Thanks @zbettenbuk - API 16 and below do not have a isPrimary column. I will add a check for that.

@zbettenbuk
Copy link
Contributor Author

@wmcmahan is there an update on this issue?

@wmcmahan
Copy link
Owner

wmcmahan commented Apr 7, 2019

closing #168

@wmcmahan wmcmahan closed this as completed Apr 7, 2019
@ParthJadav
Copy link

ParthJadav commented Mar 4, 2021

Recently, I also faced same issue. Finally, I found the solution.

First of all, you have to find all logged in gmail id from the device and then select any one gmail account and find its calendar id. After that you have to pass that id to the event query like this....

values.put(Events.CALENDAR_ID, calendarId);

at last call you function

See below method for finding email id's...

public static Hashtable listCalendarId(Context c) {
try {
if (haveCalendarReadWritePermissions((Activity) c)) {

            String projection[] = {"_id", "calendar_displayName"};
            Uri calendars;
            calendars = Uri.parse("content://com.android.calendar/calendars");

            ContentResolver contentResolver = c.getContentResolver();
            Cursor managedCursor = contentResolver.query(calendars, projection, null, null, null);

            if (managedCursor.moveToFirst()) {
                String calName;
                String calID;
                int cont = 0;
                int nameCol = managedCursor.getColumnIndex(projection[1]);
                int idCol = managedCursor.getColumnIndex(projection[0]);
                Hashtable<String, String> calendarIdTable = new Hashtable<>();

                do {
                    calName = managedCursor.getString(nameCol);
                    calID = managedCursor.getString(idCol);
                    Log.v("****", "CalendarName:" + calName + " ,id:" + calID);
                    calendarIdTable.put(calName, calID);
                    cont++;
                } while (managedCursor.moveToNext());
                managedCursor.close();

                return calendarIdTable;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

@Fashad-Ahmed
Copy link

I am having the same issue in my android pixel device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants