Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to hide an image in android?

i'm very new to android dev... i wanna know what's the best way to hide an image in android. I have an app where i take a photo, and i want that photo, can only be display inside my app.

like image 983
Fede Avatar asked Oct 06 '22 04:10

Fede


1 Answers

The best way would be using the internal storage of the device. According to the developer's site:

You can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user).

You can find all the details here: Using the Internal Storage

Bear in mind that there are some things that you should take into account; for example if that photo you mention is being taken through a camera intent the image will have to be first saved in a public folder (ie. in the external storage) for the camera to work properly and then you should move it to the internal storage (or copy it and then delete the original).

There are other methods:

  • You could also try saving the images in the external storage (accesible by others) but name the files with a preceding dot in the file name to make them invisible, but any app can access the file if they know the filename, and most file managers can show hidden files
  • Add a ".nomedia" file inside the folder to prevent the gallery from showing your pictures.
  • Name your files with random strings without extensions.

It really depends if you want to make them totally inaccessible to other apps or if hiding it a little bit it's enough

like image 70
ZhDev Avatar answered Oct 10 '22 03:10

ZhDev