Closed SongpolR closed 4 years ago
The cache filename is determined by image loader —— Fresco or Glide, if you need better name, you need handle it on your own.
Thanks for the explanation of the filename. However, I investigate more about my problem, and I figure out that I explain it wrong. The problem is not about the filename anymore, but about the file extension. All the saved files(no matter from cache or not) does not have any file extension. To open it, I have to manually append the file extension(like .jpg or .png) by renaming. I try on the demo project and got this issue as well. Any suggest?
I mean file name by the full name, including the file extension as I explained in #195.
Where should I put the logic to handle the filename? ImageLoaderCallback when the cache hit/miss?
If you want to rename the saved image file, you can do it in ImageSaveCallback
.
Thanks, now I can save the file with the name and extension as I was expecting. But, a new problem occurred instead. I got onFail
callback from ImageSaveCallback
(even though it succeeded before or not, when it failed for one time, it will keep failing all the time after that) and stack trace print something like:
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: files._data (code 2067 SQLITE_CONSTRAINT_UNIQUE)
Any clue about this issue?
Oh...I think I can figure out, I have to remove the content file from MediaStore
after successfully save the image(according). Please correct me if I misunderstand or it has a better way to do?
That sounds strange, I think adding the same image twice to the gallery should be fine, but maybe I'm wrong.
It's fine on the demo project, but I don't why it is not working on my project. Anyway thanks for your support.
I try to use
saveImageIntoGallery()
to save an image to the device's gallery, it works fine on android < 10 with a timestamp as a filename and correct extension. However, when I try on a device with android >= 10, the filename was not the timestamp anymore and the extension will be ".0" which I think came from the filename on the cache.This problem occurred on Samsung and OPPO devices, but not on the Pixel emulators(because it appends .jpg to the saved filename)