【问题标题】:Can you help to remove the file not found exception error in android? [duplicate]你能帮忙删除android中的文件未找到异常错误吗? [复制]
【发布时间】:2020-04-21 20:14:20
【问题描述】:

在 android studio 中删除错误的代码

【问题讨论】:

  • 在 logcat 中发布错误

标签: android file error-handling assets


【解决方案1】:

根据你的照片,你用错了方法。

你应该把 assignmenttitle.docx 放到 /res/raw 而不应该放到 /assets

由于文件在您的应用程序中,因此您不应使用“file:///android_asset/assignmenttitle.docx”。

这表示 Android 设备存储的文件路径,而不是应用程序的资源。

相反,你应该这样使用!

Uri uri= Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() +
                    "/raw/assignmenttitle.docx");

InputStream ins = context.get().getResources().openRawResource(R.raw.assignmenttitle.docx);

【讨论】:

  • 输入流正在工作。谢谢
  • 你好兄弟,如果我的回答对你有用,请采纳我的回答。
猜你喜欢
  • 2017-09-28
  • 2020-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-25
  • 2013-04-13
  • 1970-01-01
相关资源
最近更新 更多