1

I have been trying to get the ID of the Google Calendar installed on my device with this code:

String[] projection =                           
                              new String[]{                         
                                    Calendars._ID,                          
                                    Calendars.NAME,                         
                                    Calendars.ACCOUNT_NAME,                         
                                    Calendars.ACCOUNT_TYPE};                            
                        Cursor calCursor =                          
                              getContentResolver().                     
                                    query(Calendars.CONTENT_URI,                            
                                          projection,                           
                                          Calendars.VISIBLE +  " = 1 ",                             
                                          null,                             
                                          Calendars._ID + " ASC");                          
                        if (calCursor.moveToFirst()) {                          
                           do {                         
                              long id = calCursor.getLong(0);                           
                              String displayName = calCursor.getString(1);                          
                              // ...
                              textView1.setText(displayName + id); //outputs display name and id

                           } while (calCursor.moveToNext());

But it is only returning the Name and ID of the Samsung Calendar. Can any one explain to me why?? Thank you.

J4C3N-14
  • 686
  • 1
  • 13
  • 32

1 Answers1

1

// .. means you can get the other details yourself for example

 long id = calCursor.getLong(0);  

 String displayName = calCursor.getString(1); 

 String descriptions = calCursor.getString(2);

you can add more get more details if you want.. check this link

Community
  • 1
  • 1
earlymorningtea
  • 508
  • 1
  • 9
  • 20