0

For saving bitmap as files (png,jpeg etc) in filesDir as it received and adding the link in the room for later retrieving.

How to avoid saving duplicate bitmap as png files when saving it in filesDir.

  1. Store image hash in room to check when saving new bitmap for duplicate.
  2. Use sameAs() method of bitmap to compare all image files stored previously as png before saving.
2
  • Use a proper naming convention for Image which identify an image uniquely(You can create such name from image URL or any id you have for that object) . Then you check for file in the Dir with that name to find out if its already exists or not. If 2 different urls can have same image in your case then its a different game and can take lots of time comparing bitmap pixel by pixel. Commented Nov 5, 2024 at 4:45
  • The second option is way more expensive than the first one. Commented Nov 5, 2024 at 5:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.