【问题标题】:mkdirs not working in android studio avdmkdirs 在 android studio avd 中不起作用
【发布时间】:2018-03-16 14:04:06
【问题描述】:

我使用的是 Android Studio 2.3.3。使用 USB 设备时创建目录。但是在模拟器中没有创建目录。

代码:

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

【问题讨论】:

    标签: android android-studio android-emulator android-studio-2.3 mkdirs


    【解决方案1】:

    在模拟器设备中转到 设置 -> 应用 -> 您的应用 -> 权限 然后启用存储

    【讨论】:

      猜你喜欢
      • 2017-09-22
      • 2019-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      相关资源
      最近更新 更多