Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getContentResolver().openInputStream(imageUri) throw FileNotFoundException #95

Open
sunytan opened this issue Apr 26, 2021 · 3 comments

Comments

@sunytan
Copy link

sunytan commented Apr 26, 2021

uri: content://0@com.sec.android.gallery3d.provider/union/video/item/25473

stack:

cause by:
java.io.FileNotFoundException: Unable to get item com.sec.android.gallery3d.data.UnionSCloudVideo@882a3ac
android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698)
android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1416)
android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1253)
android.content.ContentResolver.openInputStream(ContentResolver.java:973)

device:
SM-G9350;Android 8.0.0,level 26

permission:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

this happed on Samsung device.

@yrezgui
Copy link
Contributor

yrezgui commented Apr 26, 2021

@tanyang93 Which sample are you referring to?

@sunytan
Copy link
Author

sunytan commented Apr 26, 2021

@tanyang93 Which sample are you referring to?

I referring to https://developer.android.google.cn/training/data-storage/shared/documents-files?hl=zh-cn#java

code example

private String readTextFromUri(Uri uri) throws IOException {
    StringBuilder stringBuilder = new StringBuilder();
    try (InputStream inputStream =
            getContentResolver().openInputStream(uri);
            BufferedReader reader = new BufferedReader(
            new InputStreamReader(Objects.requireNonNull(inputStream)))) {
        String line;
        while ((line = reader.readLine()) != null) {
            stringBuilder.append(line);
        }
    }
    return stringBuilder.toString();
}

@sunytan
Copy link
Author

sunytan commented Apr 27, 2021

I have confirmed that this is a problem with Samsung Album, please close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@yrezgui @sunytan and others