如何从驱动器文件

时间:2015-08-11 14:03:21

标签: android android-contentresolver drive

当我从Box Drive云存储中选择文件时,我收到的URI就像这样:content://com.box.android.documents/document/file%2C32851356501 我无法从其URI获取输入流。它是给FileIOException。

一旦我得到这样的URI,我就能从URI内容中获取输入流:文件:///storage/emulated/0/Android/data/com.box.android/241547485/cache/working/32851356501_e428a6934c285ed493f9c85acf9ab725e6f8f769 /backend_1.png

以下是我从URI中输入输入流的代码:

InputStream inputStream = null;
Uri uri = data.getData();
Log.e(TAG, "File Uri: " + uri.toString());
String mimeType = getApplicationContext().getContentResolver().getType(uri);
Log.e(TAG, "File Uri Mime: " + mimeType);

Cursor returnCursor =  getContentResolver().query(uri, null, null, null, null);

try {
    //inputStream = new FileInputStream(uri.getPath());
    inputStream = getContentResolver().openInputStream(uri);

} catch (FileNotFoundException e2) {
    // TODO Auto-generated catch block

    e2.printStackTrace();
}

我的onActivityResult中的数据意图数据

0 个答案:

没有答案