Reputation: 693
I am trying to figure out why, when I try to open an email attachment that I have an intent filter for, it is giving me a URI that I can't read from. The URI it is giving me is:
content://com.android.email.attachmentprovider/1/32/RAW
instead of:
/sdcard/Download/Attachments/MYZIP.ZIP
The code I am calling to get the path is this.getIntent().getData().getPath();
The only way that it opens correctly is by downloading it first so it has a path that I am able to access.
Upvotes: 3
Views: 4738
Reputation:
That's a custom URI provided by third party app. You should check their APIs about the permissions to work with their content URIs. Here is some information.
Normally you can use ContentResolver.openInputStream(android.net.Uri)
to get the InputStream
from that URI, something like:
import java.util.zip.ZipInputStream;
// ...
public static void test(Context context) throws Exception {
Uri uri = Uri.parse("content://com.android.email.attachmentprovider/1/32/RAW");
ZipInputStream zis = new ZipInputStream(
context.getContentResolver().openInputStream(uri));
try {
// ...
} finally {
zis.close();
}
}
But that depends on the vendor (if they provide such access or not). So make sure to check their SDK/ APIs…
Upvotes: 3