【发布时间】:2015-05-27 03:00:46
【问题描述】:
我的应用有一些问题。
我只是想读取sdcard中的文件,所以我把文件放在模拟器的/storage/sdcard/abcd(我由adb创建的文件夹)中。 文件名是“1.14P”,我验证它在那个路径中。它的权限是770。
但我的问题是,我无法通过应用程序访问 sdcard。
sampleFile = new File (Environment.getExternalStorageDirectory(), "abcd/1.14P");
sampleFile.exists() //return false
sampleFile2 = new File (Environment.getExternalStorageDirectory(), "tttt");
sampleFile2.mkdir() //return false
Sdcard 安装得很好,我想。
String state = Environment.getExternalStorageState(); //return "mounted"
我授予了权限,但我无法访问 sdcard。这是我的 manifest.xml。 (部分)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hu.test004" >
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
...(Activities)
我不明白为什么会这样。请帮我一个忙。谢谢。
【问题讨论】:
标签: android file-io android-emulator android-sdcard