MessengerPigeon/app2/src/main/java/com/epicstudios/messengerpigeon/Presenter.java
private void retrieveGroups() { //TODO DONE
        Uri uri = ContactsContract.Groups.CONTENT_SUMMARY_URI;
        String[] clms = new String[]{ContactsContract.Groups.TITLE, ContactsContract.Groups._ID,
                //ContactsContract.Groups.SUMMARY_COUNT,
                ContactsContract.Groups.SUMMARY_WITH_PHONES
        };
        String selection = ContactsContract.Groups.DELETED + "=0";// and " + ContactsContract.Groups.GROUP_VISIBLE + "=1";
        Cursor gcursor = cr.query(uri, clms, selection, null, null);

        if (gcursor != null) {

            final int titlePos = gcursor.getColumnIndex(ContactsContract.Groups.TITLE);
            final int idPos = gcursor.getColumnIndex(ContactsContract.Groups._ID);
            //final int countPos = gcursor.getColumnIndex(ContactsContract.Groups.SUMMARY_COUNT);
            final int phoneCountPos = gcursor.getColumnIndex(ContactsContract.Groups.SUMMARY_WITH_PHONES);

            if (gcursor.getCount() < 1) {
                groups.add("Found no Groups");
                groupIDs.add("NA");
            } else {
                while (gcursor.moveToNext()) {
                    String title = gcursor.getString(titlePos);
                    if (!(gcursor.getString(phoneCountPos).equals("0"))) {
                        groups.add(title);
                        groupIDs.add(gcursor.getString(idPos));
                    }
                }
                Log.d(TAG + "groups", "groups retrieved");
            }
        } else {
            //TO DO Something went wrong, except it crashes if anything goes wrong here
        }
        if (gcursor != null && !gcursor.isClosed()) {
            gcursor.close();
        }
    }
/**
     * makes list of all the groups saved on your phone(/google) by String name
     */
makes list of all the groups saved on your phone(/google) by String name
makes list of all the groups saved on your phone ( / google ) by String name
private void retrieveGroups() { 
        Uri uri = ContactsContract.Groups.CONTENT_SUMMARY_URI;
        String[] clms = new String[]{ContactsContract.Groups.TITLE, ContactsContract.Groups._ID,
                ContactsContract.Groups.SUMMARY_WITH_PHONES
        };
        String selection = ContactsContract.Groups.DELETED + "=0";
        Cursor gcursor = cr.query(uri, clms, selection, null, null);
        if (gcursor != null) {
            final int titlePos = gcursor.getColumnIndex(ContactsContract.Groups.TITLE);
            final int idPos = gcursor.getColumnIndex(ContactsContract.Groups._ID);
            final int phoneCountPos = gcursor.getColumnIndex(ContactsContract.Groups.SUMMARY_WITH_PHONES);
            if (gcursor.getCount() < 1) {
                groups.add("Found no Groups");
                groupIDs.add("NA");
            } else {
                while (gcursor.moveToNext()) {
                    String title = gcursor.getString(titlePos);
                    if (!(gcursor.getString(phoneCountPos).equals("0"))) {
                        groups.add(title);
                        groupIDs.add(gcursor.getString(idPos));
                    }
                }
                Log.d(TAG + "groups", "groups retrieved");
            }
        } else {
        }
        if (gcursor != null && !gcursor.isClosed()) {
            gcursor.close();
        }
    }
private void retrieveGroups ( ) { Uri uri = ContactsContract . Groups . CONTENT_SUMMARY_URI ; String [ ] clms = new String [ ] { ContactsContract . Groups . TITLE , ContactsContract . Groups . _ID , ContactsContract . Groups . SUMMARY_WITH_PHONES } ; String selection = ContactsContract . Groups . DELETED + "=0" ; Cursor gcursor = cr . query ( uri , clms , selection , null , null ) ; if ( gcursor != null ) { final int titlePos = gcursor . getColumnIndex ( ContactsContract . Groups . TITLE ) ; final int idPos = gcursor . getColumnIndex ( ContactsContract . Groups . _ID ) ; final int phoneCountPos = gcursor . getColumnIndex ( ContactsContract . Groups . SUMMARY_WITH_PHONES ) ; if ( gcursor . getCount ( ) < 1 ) { groups . add ( "Found no Groups" ) ; groupIDs . add ( "NA" ) ; } else { while ( gcursor . moveToNext ( ) ) { String title = gcursor . getString ( titlePos ) ; if ( ! ( gcursor . getString ( phoneCountPos ) . equals ( "0" ) ) ) { groups . add ( title ) ; groupIDs . add ( gcursor . getString ( idPos ) ) ; } } Log . d ( TAG + "groups" , "groups retrieved" ) ; } } else { } if ( gcursor != null && ! gcursor . isClosed ( ) ) { gcursor . close ( ) ; } }
makes list of all the groups saved on your phone(/google) by String name
makes list of all the groups saved on your phone ( / google ) by String name
//TODO DONE //ContactsContract.Groups.SUMMARY_COUNT, // and " + ContactsContract.Groups.GROUP_VISIBLE + "=1"; //final int countPos = gcursor.getColumnIndex(ContactsContract.Groups.SUMMARY_COUNT); //TO DO Something went wrong, except it crashes if anything goes wrong here