I'm saving a picture like so:
File dcimDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File picsDir = new File(dcimDir, "MyPics");
picsDir.mkdirs(); //make if not exist
File newFile = new File(picsDir, "image.png"));
OutputStream os;
try {
os = new FileOutputStream(newFile);
target.compress(CompressFormat.PNG, 100, os);
os.flush();
os.close();
b.recycle();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
However, when I look for the image through windows it is in the internal memory, the gallery confirms this:
This last one is confusing, it says internal memory, but then also has sdcard0
in file path.
So when does external not mean external? Is it a device set up thing, or an I miss-using/miss-understanding getExternalStoragePublicDirectory
?
getExternalStorageDirectory() Return the primary shared/external storage directory. static File. getExternalStoragePublicDirectory(String type) Get a top-level shared/external storage directory for placing files of a particular type.
Android External Storage: a place to store addition data of Android, the files that you store here is not applied the security system. Usually there are two types of external storage: Fixed external storage: Commonly understood as the hard drive of the device. Removable storage: Such as SD Card.
Android External Storage Example Code getExternalFilesDir(): It returns the path to files folder inside Android/data/data/application_package/ on the SD card. It is used to store any required files for your app (like images downloaded from web or cache files).
The MTP engine sometimes reports getExternalStorageDirectory()
as "Internal Storage", which is why it shows up under that name when you mount the device as a volume on Windows, Linux, etc.
External storage has always meant the storage that the user can access by means of a USB cable. The "Internal Storage" label is probably used on devices where external storage is part of the on-board ("internal") flash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With