I am making one android app, for which I want to store the downloaded images to sdcard or external storage.
The Android SDK offers access to external storage. Whether this is "sdcard" or something else is up to the device manufacturer.
The problem I am facing is that on some phone the images are being stored on sdcard whereas in some phones it is being stored in internal memory, specifically in samsung devices like Galaxy S4.
This code stores the images on external storage. It is not storing them on internal storage. Whether external storage is removable or not is up to the device manufacturer.
You may wish to consider reading the documentation about external storage.
You should also:
Not use string concatenation to create
File
objects. Use the properFile
constructor.Store your data somewhere better than in a hardcoded
TestApp
directory off the root of external storage, such asgetExternalFilesDir()
orgetExternalCacheDir()
. Your approach has been considered poor form for years, as it clutters up the user's external storage.Use a more-focused approach for updating
MediaStore
, such as usingMediaScannerConnection
andscanFile()
, rather than sending out an operating system broadcast, as if you were the operating system.Be sure to do all of this work on a background thread (it is unclear whether you are or are not from the code snipppet).