Era*_*ise 5 android exception-handling
我搜索了这些问题,但无法解决。请帮我解决这个问题
那是我的 mkdir 代码:
File _sdcardPath = Environment.getExternalStorageDirectory(); // sdcard path is /storage/emulate/0
File _dirPath = new File(_sdcardPath, "CreateFolder");
boolean _isCreate = _dirPath.mkdir();
if (_isCreate) {
tvResult.append(_dirPath + " mkdir success");
} else {
tvResult.append(_dirPath + " mkdir fail");
}
Run Code Online (Sandbox Code Playgroud)
我的 manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.createfolder"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我的设备android版本是:5.1.1,12GB可用空间,代码在5.0下正常运行
在运行应用程序时,我遇到了这个异常:
android.system.ErrnoException: mkdir failed: EACCES (Permission denied) when I debug step into File.mkdirs
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
518 次 |
| 最近记录: |