java.io.FileNotFoundException:/app.properties:open failed:EROFS(只读文件系统)

时间:2014-03-14 11:37:27

标签: android file-io properties-file

我想在Android应用中创建格式为.properties的文件。不幸的是,我收到错误java.io.FileNotFoundException:/app.properties:open failed:EROFS(只读文件系统)任何想法为什么?

2 个答案:

答案 0 :(得分:0)

尝试使用" android.permission.WRITE_INTERNAL_STORAGE"将其插入AndroidManifest.xml 示例如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.megazy.android"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="17" />

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

答案 1 :(得分:0)

当然你不能写一个名为

的文件
 /app.properties

因为它位于设备的顶级或根目录中,应用程序代码永远不会具有写访问权。

请参阅开发人员文档的Saving Files部分,了解存储文件的有效位置,以及且不需要其他可实现的权限的位置。