我正在开发华硕nexus 7,我正在将数据写入内部存储文件。在运行时我收到以下发布的logcat输出,其中有案例的应用程序 终止。
相同的应用程序针对三星galaxx note 3进行了测试,它运行良好而不会崩溃
我想知道如何在针对华硕nexux 7进行测试时修复这些错误以及为什么会发生这种情况。
注意:添加了在外部存储上写入所需的权限 请告诉我代码中缺少的内容
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
logcat的:
: +++++ isExternalStorageMounted() +++++
11-26 15:53:51.329 24003-24003/com.example.com.bt_11 D/IOCtrl: isExternalStorageMounted(): -> media state: mounted
11-26 15:53:51.330 24003-24003/com.example.com.bt_11 D/IOCtrl: dir: /storage/emulated/0/CAN_BUS already exists
11-26 15:53:51.330 24003-24003/com.example.com.bt_11 D/IOCtrl: file: Test_00.txt will be created
11-26 15:53:51.330 24003-24003/com.example.com.bt_11 W/System.err: java.io.IOException: open failed: EACCES (Permission denied)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at java.io.File.createNewFile(File.java:939)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.IOCtrl.createFile(IOCtrl.java:87)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.ActConnect2$ATRx.onPreExecute(ActConnect2.java:844)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:604)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.ActConnect2$ATConnect.onPostExecute(ActConnect2.java:702)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.ActConnect2$ATConnect.onPostExecute(ActConnect2.java:574)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:651)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask.-wrap1(AsyncTask.java)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.Looper.loop(Looper.java:148)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at libcore.io.Posix.open(Native Method)
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 W/System.err: at java.io.File.createNewFile(File.java:932)
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 W/System.err: ... 14 more
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 E/IOCtrl: <<createFile>>: Error creating file: open failed: EACCES (Permission denied)