java.io.FileNotFoundException:/data/test.xlsx(权限被拒绝)

时间:2013-07-17 10:07:54

标签: android file

我已经在清单文件中给出了读写权限,但我得到了这个例外。

       07-17 15:23:47.886: W/System.err(384): java.io.FileNotFoundException:         /data/test.xlsx (Permission denied)
       07-17 15:23:47.906: W/System.err(384):   at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
       07-17 15:23:47.915: W/System.err(384):   at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
       07-17 15:23:47.915: W/System.err(384):   at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
       07-17 15:23:47.915: W/System.err(384):   at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
       07-17 15:23:47.915: W/System.err(384):   at java.io.FileOutputStream.<init>(FileOutputStream.java:144)
        07-17 15:23:47.915: W/System.err(384):  at com.example.excelreader.MainActivity.onCreate(MainActivity.java:44)
        07-17 15:23:47.915: W/System.err(384):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
        07-17 15:23:47.926: W/System.err(384):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
        07-17 15:23:47.926: W/System.err(384):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
        07-17 15:23:47.926: W/System.err(384):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
        07-17 15:23:47.926: W/System.err(384):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
        07-17 15:23:47.926: W/System.err(384):  at android.os.Handler.dispatchMessage(Handler.java:99)
        07-17 15:23:47.926: W/System.err(384):  at android.os.Looper.loop(Looper.java:130)
        07-17 15:23:47.926: W/System.err(384):  at android.app.ActivityThread.main(ActivityThread.java:3683)
        07-17 15:23:47.936: W/System.err(384):  at java.lang.reflect.Method.invokeNative(Native Method)
        07-17 15:23:47.936: W/System.err(384):  at java.lang.reflect.Method.invoke(Method.java:507)
        07-17 15:23:47.936: W/System.err(384):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        07-17 15:23:47.936: W/System.err(384):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        07-17 15:23:47.957: W/System.err(384):  at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

普通用户无法访问

/data。事实上,如果你从adb运行

adb shell ls /data

你会得到

opendir failed, Permission denied

数据具有以下权限

drwxrwx--x system   system            2013-07-16 10:09 data