Android - programmatically read incoming / outgoing emails for google account (Gmail app installed / not installed)

I am trying to read incoming / outgoing emails from my main google account. But I cannot do this. I followed the source code (it was installed for the Gmail app)

ContentResolver cr = getContentResolver(); 
Cursor unread = cr.query(Uri.parse("content://gmail-ls/conversations/"), null, "label:^u", null, null); 
int subjectIdx = unread.getColumnIndex("subject");

do {
   String subject = unread.getString(subjectIdx); 
} while (unread.moveToNext());


taken from a question from stackoverflow (forgot link, I feel bad) but it doesn't work. Is there a way to read incoming / outgoing email for the main google account.


source to share

All Articles