我正在使用Android studio 2.3.3。何时使用USB Device目录创建。但是在模拟器中没有创建目录。
代码:
String SDK= Environment.getExternalStorageDirectory().getAbsolutePath();
String DB=SDK+"/MathEdu/DataBase";
File file=new File(DB);
file.mkdirs();
if (file.exists ()){
Log.i("log", "exists");
} else{
Log.i("log", "not exists");
}
在我的Android.Manifest.xml中我有
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
和Logcat:
10-05 06:43:23.145 3001-3001/? I/art: Not late-enabling -Xcheck:jni (already on)
10-05 06:43:23.145 3001-3001/? W/art: Unexpected CPU variant for X86 using defaults: x86
10-05 06:43:23.197 3001-3001/ir_100110.mathedu W/System: ClassLoader
referenced unknown path: /data/app/ir_100110.mathedu-1/lib/x86
[ 10-05 06:43:23.208
1834: 2021 D/ ]
HostConnection::get()
New Host Connection established 0x94a83fc0, tid 2021
10-05 06:43:23.240 3001-3001/ir_100110.mathedu W/art: Before Android 4.1,
method android.graphics.PorterDuffColorFilter
android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
10-05 06:43:24.191 3001-3016/ir_100110.mathedu I/OpenGLRenderer: Initialized EGL, version 1.4
10-05 06:43:24.191 3001-3016/ir_100110.mathedu D/OpenGLRenderer: Swap behavior 1
10-05 06:43:24.191 3001-3016/ir_100110.mathedu W/OpenGLRenderer: Failed to
choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
10-05 06:43:24.191 3001-3016/ir_100110.mathedu D/OpenGLRenderer: Swap behavior 0
10-05 06:43:26.875 3001-3001/ir_100110.mathedu I/log: not exists
答案 0 :(得分:0)
在模拟器设备中转到 设置 - &gt;应用 - &gt; 您的应用 - &gt;许可强> 然后启用存储