只读文件系统android studio

时间:2017-03-08 18:29:27

标签: android android-studio filesystems

我正试图点击按钮打开pdf。日志中不会弹出任何错误,但每次单击按钮,我都会在运行日志中获得“E / tag:Rota.pdf(只读文件系统)”。我尝试使用adb命令更改文件系统,但什么也没做。任何想法?

2 个答案:

答案 0 :(得分:0)

检查您是否已在清单文件中添加了读取外部存储空间的权限。

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

pdf文件在哪里?

答案 1 :(得分:0)

五月this可能会对您有所帮助。

如果打开PDF文件有问题,请尝试以下代码。

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+ filename);
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(Uri.fromFile(file),"application/pdf");
target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

Intent intent = Intent.createChooser(target, "Open File");
try {
   startActivity(intent);
} catch (ActivityNotFoundException e) {
// Cathc exception here
}

您可以尝试使用Uri指向该文件的ACTION_VIEW Intent(在SD卡上或在应用程序本地文件存储中的MODE_WORLD_READABLE)和MIME类型" application / pdf"。

如果Android Studio有问题debug,请在此处发布有用的日志。