0

This was the code i was using but it didn't work as i couldn't find any folder created.

File myDir = new File(getCacheDir(), "123");
myDir.mkdir();

The next code also wasn't working.

File mydir = context.getDir("users", Context.MODE_PRIVATE); 
if(!mydir.exists) 
{
    mydir.mkdirs();
}     
fantaghirocco
  • 4,761
  • 6
  • 38
  • 48
AbhiWill12
  • 17
  • 4

3 Answers3

0

You won't see it on your SD-Card as long as you are using MODE_PRIVATE. Only your application can access that folder. You probably can try Environment.getExternalStorageDirectory().

Endre Börcsök
  • 477
  • 1
  • 8
  • 19
  • i am trying to make one in internal storage as kitkat and above applications are not allowed to Read and Write External Memory – AbhiWill12 Mar 17 '16 at 15:35
  • In that case you are doing it right. Does getFilesDir().list() return the folder you made? (After calling mkdirs() obviously) – Endre Börcsök Mar 17 '16 at 15:53
0

Hope this helps:

File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir;
File fileWithinMyDir = new File(mydir, "myfile"); //Getting a file within the dir.
LoveForDroid
  • 1,072
  • 12
  • 25
0

i couldn't find any folder created

You and users cannot access internal storage, except via some command-line tools, or by using an emulator, or by using a rooted device.

The next code also wasn't working

That is also internal storage.

If you are expecting to see something when you plug your device into your desktop OS, that is external storage from the standpoint of the Android SDK. You also have to use MediaScannerConnection and scanFile() to get any files created on external storage to show up when you browse through your desktop OS file manager.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491