1

First of all, I'm an android newbie. Now my question...

I want to create a folder with some files, so I can easily access them when I plug in my droid via USB.

"directory.exists" returns true, saying the folder exists, but when I go to Windows File Explorer, Computer\Nexus 5\Internal storage, I do not see my app folder listed in there.

getExternalStorageDirectory returns: /storage/emulated/0/MyAppName

File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyAppName/");

if (!directory.exists()) {
    directory.mkdir();
}

I have added

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

in manifest. What am I doing wrong?

live-love
  • 48,840
  • 22
  • 240
  • 204
  • 1
    the USB file connection on Android is cache based, that means, if your app just created the files and you immediately tries to check on the PC it will probably won't show. Try downloading a File Manager on your phone and check if the folder is there via the manager, if it is, it will probably show up for your PC after sometime or after you reboot the phone. – Budius Sep 02 '14 at 15:02

1 Answers1

1

You're not doing anything wrong. Android does.

That MTP connection is unreliable as contents displayed is not in sync with the latest files wrote on the phone.

You can cause a manual rescan or reboot the phone... see below:

Community
  • 1
  • 1
RumburaK
  • 1,985
  • 1
  • 21
  • 30