0

In android KitKat there are some limitations for writing to SDcard.

So my question: Is it always permitted to write to Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) even in KitKat?

wilddev
  • 1,904
  • 2
  • 27
  • 45
  • No. With INTERNET permission requested in your manifest yes. The external storage you mention has nothing to do with an SD card though. – greenapps Apr 08 '15 at 11:28

3 Answers3

3

Is it always permitted to write to Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) even in KitKat?

If your app has requested the WRITE_EXTERNAL_STORAGE permission, then yes, as getExternalStoragePublicDirectory() points to external storage, which is not removable storage ("SDCard") on the vast majority of devices.

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

You first need to understand concepts of Android Storage. Then you will understand that Environment.getExternalStorageDirectory() or something like that is about primary external storage. And it has nothing to do with Android APIs whether it is younger or older than KitKat.

Community
  • 1
  • 1
SilentKnight
  • 13,761
  • 19
  • 49
  • 78
0

To get the internal SD card you can use

String extStore = System.getenv("EXTERNAL_STORAGE");
File f_exts = new File(extStore);

To get the external SD card you can use

String secStore = System.getenv("SECONDARY_STORAGE");
File f_secs = new File(secStore);

On running the code

 extStore = "/storage/emulated/legacy"
 secStore = "/storage/extSdCarcd"

works perfectly!

refer following Link , I think ur question has been answered already check this...

Android Open External Storage directory(sdcard) for storing file

Community
  • 1
  • 1