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.
Related
I've 100's of .gif images to be used in a android application that I'm trying to build. Can any one suggest me how should I minimize their size. And should I place them in drawable directory.
Google play has a limit on APK size which can be uploaded to playstore(if I am not wrong its 100Mb), so having so many .gif files inside application drawable folder will not be a solution.
Best solution I could think of right now is via Dynamic asset delivery by google play.
Please go through below for more info on asset delivery
https://developer.android.com/guide/app-bundle/asset-delivery
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'm using Universal Image loader to retrieve a lot of images from a server and showing it inside a listview.
Now when cache is full, library remove automatically some "old" images for free space to keep new on, so when i scroll "back" for see previous images (that was deleted from cache), library download it again.
This is a very big problem if library recover picture using a 3g connection.
What i want to do is:
-recover picture from link
-save pic in cache (library already do this)
-save pic into a folder on storage too
so when library need to show again an old picutre that is not still into chache, it could recover it from storage, and not from web.
It's possible to do it?
I think the batter way is you use UrlImageViewHelper you can download from https://github.com/koush/UrlImageViewHelper
it will handle automatically store the image in cash memory it's a better way to use this lib to load image.
Yes you Can First you have to store images in specific folder while doing activity for first time later you can put small piece of code to check that requested file is present on local storage folder ..... thats will solve your Problem
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.
I made a application in which many images are shown,
all images are pre-stored in drawable folder of resources,
but if i want to add new picture then how can i do this,
it should read from memory card but only once, after that it automatically load.
If I understand correctly, you want to upload images yourself to the app instead of letting user use images or..?
If it's you, who should upload new images, you can download them to the app with a check if there are new ones.
If it's the user, you can check their gallery on the sd card, but unfortunatly I don't think it's possible to store these in the drawable folder.
You mean you want a dynamic drawable folder? You cannot do that since APK file is read only...
you cant do this, because it is an impossible act, Drawable folder is meant to make the Application Environment when it is deployed, it is a one way process. you can copy Drawble image to external path