0

I am trying to create folder in external storage through my app.

The problem is that things work fine and as expected, except the Nexus 5 phone. The issue is that folder is shown as file. But when the phone is restarted then it shows correctly as a folder.

I think media scanner is not working. So for that I called media scanner explicitly but its not being called. For that reason I did some research and found that its specified over Google docs that from 4.4.2 media scanner could not be called from all apps.

I need help because after running app and creating folder app could be restarted again and again.

Edit

There are no errors coming, but if you try to access the folder it says:

directory not found

After restarting phone it works. Creating directory code:

File folder = new File(Environment.getExternalStorageDirectory() + "/myfoldername");
boolean success = true;
if (!folder.exists()) {
    success = folder.mkdirs();
Sufian
  • 6,405
  • 16
  • 66
  • 120
Suraj Pohwani
  • 138
  • 1
  • 9
  • show us errors, or some pieces of code.. – Teo Jul 10 '14 at 09:45
  • @Teo there are no errors coming, but if you try to access the folder it says directory not found. After restarting phone it works. And about code its simple creating directory code. `File folder = new File(Environment.getExternalStorageDirectory() + "/myfoldername"); boolean success = true; if (!folder.exists()) { success = folder.mkdirs();` – Suraj Pohwani Jul 10 '14 at 09:51
  • A recommendation. Use `new File(dir, filename)` instead. – Sufian Jul 10 '14 at 10:09
  • This may help you ? http://stackoverflow.com/questions/22366217/cant-create-folder-on-external-storage-on-android – hungr Jul 10 '14 at 10:29

0 Answers0