I have to do some stuff. I'm downloading images using web-service, after successful download of each image, I'm using "AES" encryption algorithm to encrypt that images. I'have done encryption successfully. But whenever I'm going to open Gallery of device, I am able to seen that downloaded images encrypted by me. I don't want that. I wanna secure that images that can prevent access from Gallery.
I understood the whole process here.When I am storing each image after download Gallery capture that image and store into its cache so before my encryption process may be Gallery populate that images.
-> My Encryption process : Download Image - > Store into SDCARD - > Encrypting Image - > Delete the real Image
But this is not deleting from Gallery also.
So in short I wanna secure that images that can prevent access from Gallery. Let me know your best suggestion about my process is right or wrong? May I have to do a few changes on it? or have you nice idea instead of my process ?
Thanks for your best suggestions.
You must add an empty file to your images folder called .nomedia. This will prevent the MediaScanner from indexes images in that folder.
However, there is a bug on ICS that makes this slightly harder. On ICS, your folder must have the .nomedia present before you add images to it, or else the images will be indexed.
Another, slightly less compliant option is to begin your folder name with a dot (something like .foldername). As Android is UNIX based, this will make it a hidden folder, and hence not have the MediaScanner scan it.
I have got a proper solution. That will also work with higher versions.
You can keep it private with your application's private folder using following directory :
String mDirectory = getPackageManager().getPackageInfo("com.example.myapp", 0).applicationInfo.dataDir;
You can store your private data into this package. It will prevent access as well as prevent indexing from Gallery. So you don't need to worry about it's encryption process also :) . May be this folder will not provide much space. But atleast it will be help us.
Sounds like below solution might work for all versions -
(Storing videos, images and audio files that can not be accesses by others)
For this you have to store your data in External Storage with creating a folder name starting with the .(dot) then this folder is hidden from the FileExplorer.In this folder you need to create a .nomedia file and place your Images and video then images and videos are can not be visible to User in the Gallery.nomedia folder files can not be read by the gallery.
Related
My Android app creates a folder on the users device's external storage on launch:
File images = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "rapical" + File.separator);
images.mkdirs();
I have around 16 image icons (.png) that I would like to place in this folder the first time the user opens the app.
What is the best practice to do this? Should I place them in the drawable folder initially and then copy them over to the newly created images folder? Not sure what approach to take!
There are two separate issues here:
What to do with images that the user adds to your app?
What to do with your starter images, for your default foods?
Using external storage for the user-added images has some implications:
Your app can survive that image no longer existing, since the user, or other apps, can delete that file at any point
Your user does not mind that the image will get picked up by other apps, such as photo galleries
Unless you specifically want these images to be user-manipulable outside of your app, I suggest that you use internal storage for the "re-sized, compressed and stored" user-supplied images. The original image might be on external storage (I assume that you are using ACTION_GET_CONTENT and/or ACTION_OPEN_DOCUMENT to get the image), but your modified copy would be private to your app.
I sincerely hope that you are using an image-loading library, like Picasso, for loading these images, since they will handle things like background threads and ListView/RecyclerView image recycling and stuff for you.
In that case, what you store in the SQLite database for your default foods needs to be something that the image-loading library can interpret, to bring in the image that you want.
In that case, I would suggest using assets/ to ship the images and file:///android_asset/... values in the database. file:///android_asset/ points to what amounts to assets/ in your project, so if you have assets/chicken_pad_thai.jpg in the project, Picasso (and any decent image-loading library) would be able to interpret file:///android_asset/chicken_pad_thai.jpg) and load the image.
This saves you from making duplicate copies of the images, saving the user disk space and time on first launch. It also means that if you replace the images in your app (e.g., you get a better photo representing chicken pad thai), the user will start seeing the updated image, without you having to do some extra work to realize that you shipped a new image and have to copy that image out to a file somewhere.
Now, suppose that you really do want the user-supplied images to be on external storage. In that case:
Probably rather than the directory that you chose, I would go with getExternalFilesDir() (a method on Context), as on API Level 19+, you do not need WRITE_EXTERNAL_STORAGE as a permission
If you want the user to be able to manipulate the images of the default foods, then copy those out to that location on first run
I need to make an application, which will be a gallery of several pictures, supplied with the application when downloading app from Play store.
Could you suggest how this is best done in the future to facilitate the addition of new images?
I know how to do to gallery took the images from a folder on your device, but how to put these images together with the application from Play Store? We need them as a resource to unpack?
Thank you!
You have 2 basic options.
Download images from internet on runtime - supplied by your server which you can control and therefore add new images without the need of updating the application.
Or you can just put images into your /drawable folder within app and every time you add new image there you update your app on play store.
if you put all the image in the drawable folder then the application is going to be very big. I would suggest putting the images on a image hosting cdn like cloudinary then use an image downloader to pick the images from the url and cache them on the device like Picasso or Universal Image Loader. Also you dont want to be shipping updates just because you want to add a few images.
I think there are 2 ways to do it:
(1) Put the pictures to web server. The apps can download the new picture from web server and store to device's local memory.
(2) Put the images to /Asset folder and submit app update to Google Play when you want to add more pictures to the Apps.
I'm not sure what you mean as a resource to unpack, but the simplest option is to include them as drawables.
If you do not want to do that, you can include them in the assets or raw resources directories. Assets is often used for some images raw might be used if you were for instance including some other format to unpack as you said, bit that comes with its own issues.
I'm developing an ebook reader app for Android. The special books for this app are zipped files of some html/css/js/image/... files which are in a server and will be downloaded by the app. Each zipped file may have 1-5 MB and if extracted, a lot more than that.
I was wondering, regarding to android guidelines, where is suitable to
Put the zipped book files?
Put the extracted files when they are being used?
Well, if you actually need to save that data when app finishes, you should use sd-card, since it has more space, but if you only download image one time, just to show it on screen than use internal storage. Also consider your lowest API since that will be phone with least storage, and your app needs to work there as well as on new devices. Either way if you have to make several files while extracting data, use internal storage because it will be faster, and move it later to sd card if you actually need to save it.
I need to store the list of downloaded image in device.I need to know what is the best way for storing images.If i store it in sd card when the user removes the sd card from device.In that situation how to overcome this problem.
If you are bothering about the sdCard removal then only on option is available to save on phone memory that is always available.
Or if you have Internet available what about moving to cloud ???
but if the main concern is security of Images you can go with the answer of user #shree202
For the security purpose you can change the extension
Say From JPG ==>> .db
it is use less for other applications and also user manually can't change the extension
and also for more secure way You can encrypt it by changing it to byte.
If you are going to open the images right from your own application, then, you can remove the extension of the image file and then save. After that, while accessing the image you can get the file list and display it again in your application by appending the file extension.
I'm using an expansion file (~500mb) that contains videos and more than 20.000 image files.
Which is the best way to manage this file?
For now, i'm loading the ZipFileResource object in my Application class when i check if this file is already downloaded.
One of the uses for this expansion file, is to provide images for a gigapixel view, but it takes a lot of time to load one image, and it should load about 30 images in 200ms.
Before i move this image files to an expansion file, there were in assets folder and worked well.
I'm planning unzip the expansion file at the external storage and remove the obb file, but i don't know if it's a good choice.
Can you tell me some advices?
Thanks in advance.
As far as I understood you, you'll download your mediafiles after you have installed the App. For this I would make it like that, download it and save it to the SD-Card (I would do this in an AsyncTask). Now you save every path of your picture or video into your DB. If you want to get the picture read it out the db and fill your ImageView or whatever. This way is really fast.
I hope I could help you.
safari
I tried to use Zip files as extension files once and I have found that they work very slowly.
OBB files works fast, just as with your regular file system.
I'm planning unzip the expansion file at the external storage and remove the obb file, but i don't know if it's a good choice.
It's bad choise. Google doesn't recommend:
To ensure proper behavior, you must not delete, move, or rename the expansion files.