Android: Failed to ensure directory when getExternalFilesDir(null)

Jerome picture Jerome · Jan 2, 2015 · Viewed 7.7k times · Source

As shown in the title, when I called the method getExternalFilesDir(null), i got a warning like this: Failed to ensure directory: /storage/emulated/0/Android/data/com.xxxx.app/files

So, it turns out that the i cannot get the path /storage/emulated/0/Android/data/com.xxxx.app/files Also, the problem only happens sometimes.

Answer

Chakir picture Chakir · Sep 18, 2015

This happened to me when uninstalling the app and reinstalling it. But probably the resources of the app (com.xxxx.app in your case) had a reference not released.

The solution was quite simple: just stop and relaunch the emulator, or reboot the phone should do the trick.