- android — save image into gallery
- 12 Answers 12
- How To Properly Save To The Pictures Folder
- Where are images stored on Android? What is the DCIM thumbnails folder?
- Written by: Ilia
- Where are pictures stored on Android?
- The DCIM Folder
- Where screenshots are saved on Android phone
- Why we need a thumbnails folder
- Where thumbnails are stored
- How to delete thumbnails on Android phone
- The DCIM folder is empty – now what?
- Clearing the Cache
android — save image into gallery
i have an app with a gallery of images and i want that the user can save it into his own gallery. I’ve created an option menu with a single voice «save» to allow that but the problem is. how can i save the image into the gallery?
this is my code:
i’m not sure of this part of code:
is it correct to save into the gallery? unfortunately the code doesn’t work 🙁
12 Answers 12
The former code will add the image at the end of the gallery. If you want to modify the date so it appears at the beginning or any other metadata, see the code below (Cortesy of S-K, samkirton):
Actually, you can save you picture at any place. If you want to save in a public space, so any other application can access, use this code:
The picture doesn’t go to the album. To do this, you need to call a scan:
I’ve tried a lot of things to let this work on Marshmallow and Lollipop. Finally i ended up moving the saved picture to the DCIM folder (new Google Photo app scan images only if they are inside this folder apparently)
And then the standard code for scanning files which you can find in the Google Developers site too.
Please remember that this folder could not be present in every device in the world and that starting from Marshmallow (API 23), you need to request the permission to WRITE_EXTERNAL_STORAGE to the user.
Источник
How To Properly Save To The Pictures Folder
I am trying to save a bitmap that is created by the user to the default ‘Pictures’ folder on the device. I will start with the option that seems to be the more common method:
This is supposed to save to the ‘Pictures’ folder, but Environment.getExternalStorageDirectory().getAbsolutePath() seems to create a new file structure like this file://storage/emulated/11/Pictures/ and save the picture to that. I have also tried Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) with the same result. But this is not the default ‘Pictures’ folder on any of my test devices or emulators. Which led me to look for other methods, and I found this:
This actually saves to the default file structure, which apparently looks like this: content://media/external/images/media/4282 . But there seems to be no way to specify the filename of the image ( Media.TITLE just sets the title attribute, not the actual filename), it saves as a (seemingly) random string of numbers. I looked at the API Guide for MediaStore.Images.Media and there does not seem to be any other variable that would set the filename. This also does not seem to be the correct way of saving, according to the Android Developer Guides. I would like to know if there is any way of saving to this folder, while also setting my own filename. And if this method could produce unforeseen problems on other devices.
EDIT: For anyone interested this is my current code, based on the answer by @CommonsWare:
Источник
Where are images stored on Android? What is the DCIM thumbnails folder?
Written by: Ilia
Data recovery specialist, guest author, journalist.
It is convenient to store pictures on your phone,but with time it becomes harder and harder to clean up. Moreover, it isn’t always very clear where the images are stored. Worst of all, whole photo albums might disappear with an unintentional swipe. That’s why it is important to know where the media files are stored.
In this article we will describe:
Where are pictures stored on Android?
Photos taken on Camera (the standard Android app) are stored on either a memory card or in phone memory depending on the settings of the phone.
The location of photos is always the same — it’s the DCIM/Camera folder. The full path looks like this:
How do you get to these folders fast? You need to install a file manager like ES Explorer or Total Commander since the built-in tools of the mobile OS are not very convenient and have limited abilities to work in files and folders.
The DCIM Folder
DCIM stands for Digital Camera Images. This name is standard for digital cameras.
iOS and Android devices support DCF (Design rule for Camera File System); the name DCIM is accepted within the framework of DCF. Desktop and mobile apps can easily open this folder.
Where screenshots are saved on Android phone
Screenshots taken in the usual way (i.e. by pressing hardware buttons) are saved in the Pictures/Screenshot (or DCIM/Screenshot) folder. If you install a third party Screenshot app on Android OS, you need to check the screenshot location in the Settings.
Why we need a thumbnails folder
As the name suggestions, in this folder you can find thumbnails — smaller versions of pictures and downloaded images, for example, contact photos from Whatsapp or Skype. Thumbnails help a smartphone to open an image from the Gallery more quickly.
Where thumbnails are stored
Thumbnail files are stored in DCIM folder:
How to delete thumbnails on Android phone
It often happens that thumbnail files “eat up” too much space on a phone, up to a few gigabytes. It is useful and sometimes even necessary to clean out the thumbnails folder. You lose nothing, as all the necessary files will be created again when needed.
You can clean out the files in two ways.
Method 1 (manually):
1. Install a file manager on Android (for example, Solid Explorer Classic).
2. Enable the viewing of hidden files in your phone.
3. Go to the thumbnails folder.
4. Delete the Android DCIM thumbnails content by selecting all files.
Method 2 (automatically):
1. Install CCleaner app on Android.
2. Tap the ‘Analyze’ button.
3. Go to the ‘Other Caches’ section.
4. In the results tap the checkbox ‘Thumbnail Cache’ and press ‘Clean’.
The DCIM folder is empty – now what?
This problem occurs when you connect your phone to a PC through a USB cable. The DCIM folder is empty while the pictures can still be displayed through Gallery
- You need to check both locations — on the memory card and on the Android-device memory. (You may need to drag files from one DCIM folder to the other.)
- Then delete cache from External Storage and Media Storage app.
Clearing the Cache
1. Settings > Apps > Tap three dots on top right.
2. Show system apps > Go to ‘External Storage’ and ‘Media storage’.
3. Tap ‘Clear data’ and ‘Clear cache’ buttons.
4. Reboot the mobile phone.
Why is the folder called DCIM?
The abbreviation DCIM stands for Digital Camera Images. For digital cameras this name is a kind of standard.
iOS and Android devices support the DCF specification, within which the DCIM name is adopted. Therefore desktop and mobile apps open this folder with no problems.
I accidentally deleted photos from the Camera folder to make space. I chose the DCIM folder as the one to erase by accident too. Is it possible to recover the photos? It happened 5 days ago.
Thumbnails from the DCIM folder can be recovered even without root access, but it’s required if you want to retrieve the original photos. We’ve already discussed such cases here and we recommend you to go through the cases of other users.
I have a Samsung Galaxy j5 smartphone and all my photos and videos went missing. I looked for them in the DCIM folder but found nothing when the memory of the phone is still occupied.
See the general recovery tips we’ve given in this article. Also consider checking other spaces (such as Samsung Cloud, Google Photos or Dropbox) for any backup copies.
I’ve transferred the photos from my phone to a SD card but instead of them I see a triangle with an exclamation mark. The photos stored in the DCIM camera folder are of poor quality and resolution.
Your files got lost during the transferring process. This often happens when cut-and-paste is used instead of copying and deleting. Your way out of this situation is to try to recover the photos from your phone memory and here you can find the best software for this purpose.
After restarting a device, its SD card was damaged; all the photos/videos stored on it were lost.
The memory card has to be checked for reading errors. Here is the manual on how to do it. If you can’t fix the storage drive, give a try to recovering the photos and videos via PhotoRec software. In order to do it, connect the SD card via a card reader to a PC.
After I take a picture I used to put it on autocorrect and it would send it to DCIM folder which was thin located in my gallery when I scrolled down but it is not there anymore and I cannot find my DCIM folder. Where are my photos? I’ve already gone through your instructions and do not understand a word they’re saying. I want my DCIM folder back because the pictures look better.
I have a Samsung galaxy j5 and some saved images on my phone went missing. I went through my files and DCIM folder but found nothing, although no additional free memory appeared. I receive Android notifications saying that I need to free up some memory. What should I do?
I transferred photos from my phone to its memory card, but they disappeared and instead of them there is a triangle with an exclamation mark… I found the photos (on your advice) in DCIM camera folder, but their quality leaves much to be desired (the focus is completely gone!).
I transferred the photos from my phone memory to its sd card. I made it via a stationary computer by connecting the phone through a USB port. I have access to Android Gallery and photos are stored in DCIM/Camera folder. But there is no access to the photos and videos from Viber and WhatsApp.
Please help me to recover the files from my phone. When I connect it to my computer, the photos stored in DCIM folder (internal memory) can’t be viewed, although there are no problems with it when viewing them via the phone. I wanted to transfer them to the computer. As a result, I’ve done something wrong. Now all the photos in this folder are in the form of a gray square with an exclamation mark. When I try to open them, the cursor hangs and starts spinning and then I receive a notification saying that the format isn’t supported. I have no clue how but two DCIM folders merged and then were replaced. As a result, there is some free space in the internal memory of the phone. In such case is it possible to retrieve photos and videos from that folder and if yes, than how?
Источник