I know a way to get the Name of attachment in email shown here: Android - get email attachment name in my application.
But could not read actual file which was attached. How do I read that attached file in application programmatically?
I tried this code in which byte array is always null. What am I doing wrong:
public static String getContent(ContentResolver resolver, Uri uri)
{
Cursor cursor = resolver.query(uri, new String[] { MediaStore.MediaColumns.DATA }, null, null, null);
cursor.moveToFirst();
int nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
Log.d("column", nameIndex + "");
if (nameIndex >= 0)
{
byte b[] = cursor.getBlob(nameIndex);
return b.length + "";
}
else
{
return null;
}
}