Confusion over apk resource files and internal/external files in Android - android

I am writing an app that has a HorizontalSrollView composed of a LinearLayout that is composed of ImageViews.
I have default images for the HorizontalScrollView in the res/drawable folder. These images should check against a list of images on a server somewhere and if the files are different, the new ones should download and other files that doesn't exist on the file but on the device should be removed.
All that works, except for during my debugging process I have a question. Every time I click "run" on eclipse, does the internal and external storage of my app get removed clean or do the files stay there even if I am installing a newer "version" of my app?

Related

Downloadable files in my application

I created a project which uses Fragments, and in one of them I want to add some clickable icons that will allow to download a file (one per icon).
I have the files stored on my computer.
I suppose that they have to be copied into my application.
How I can implement this in the code?
I hope that this picture can explain what I want to do.
will allow to download a file and they have to be copied into my application don't match: If the files are already on the device (once your app is installed), what is the sense of downloading those files again?
Therefore, either provide your files inside your app or use a file server and download them.
If you decide to provide the files in your app, this will increase the installation time.
But it would not require an internet connection to download the files again.
So, simply put your files in the raw or in the assets folder and that's all.
Then simply access your files from that folder.
If the folder isn't already found in your project, simply create it and drop your files in it.

Access and edit files in runtime android app

My game is fed by parameters from a text file.
When I run the game in Unity, I can set the file path to my desktop or whatever and that works perfectly.
The problem is that when I run the game on an android device, I have to set the file path to some local folder in the device, a folder which I'll have access to.
How can I do that?
I want the file to be part of the .apk file.
I'm sure there's a way for doing that, yet could not find some relevant information on the internet.
I had a similar problem as your, I had to load some Translation Text Files in my game.
You can save the text file in the Resources folder. Then load it at runtime with Resources.Load("folderInsideResourcesFolder\textFile"). The Resources folder will be packaged in the APK.
You can find more info here: http://docs.unity3d.com/Manual/LoadingResourcesatRuntime.html

create an android apk that only update a resource image file

Is it possible to create an .apk file that only update an image in the existing app? my app is an in-house app for corporation, not in the play store, mainly contain of images (in the resource folder), and i just want to create a patch (an apk that is significant smaller size) that only update one of the images in the existing version.
If you want your app change image in the res folder of another app it may be possible(not sure it can be impossible at all) for rooted devices.Because all app folders created by the android system for the installed application are protected and can not be accessible for another processes.
But if the image was created on SD-card or on the shared device memory it is not a problem.

Android distribute files with app

When I complete the Android app I am developing I will want to distribute it so that about 300 image files are stored on the sdcard. Is there any way to do this within the usual automatic installation system? I don't want to hog the internal memory by including the files in res/raw.
I believe the app can now be built with an instruction to install on the sdcard so I suppose I could do that and include the files in res/raw but is there any limit on the number of files in res/raw?
If you didn't want to include the images you could utilize the APK Expansion Files mechanism:
http://developer.android.com/google/play/expansion-files.html
It will even save it to the sdcard.
Otherwise, you will either have to include the images or download them programmatically to the sdcard. As for the limits of the res/raw/assets folder I couldn't find any hard figures. The upper limit though would be the max size of the apk. You could always write a little script that would place 5k/10k/20k 1byte files and see for yourself on that upper bound. If the actual amount of files became an issue you could always zip them in the assets/raw and unzip them to external storage.
I have personally shipped an application for a client that had upwards of 500 images in the assets folder and it worked very well.

How to provide some resource files for an android application?

I'm writing an android application, which user can download some image files from server. There image files will be stored in android mobile.
Now I want to put some of image files inside the apk file, that user can start the application quickly after installing. I found I can put them into assets directory, but the directory is read only. When user download other image files, I need to store them into another directory.
So there will be two directories to store the image files, but they are the same type.
Is there any good solution for this case?
Check out http://developer.android.com/guide/topics/data/data-storage.html#filesInternal for a listing of different places you can put data on Android.
You should put downloaded image files into one of three places, depending on your needs.
If the images are meant to be viewable by the user (e.g. downloaded photos), put them on the external storage. If they are meant to be user-interface elements or other crucial (but not user-facing) images, put them on internal storage. If they are meant to be cached for quick access but downloaded if necessary (e.g. temporary images like those found on a website), put them in the internal cache directory (Context.getCacheDir()).
If you don't have a lot of assets, you can copy them to the target location when your program first runs (e.g. check for the existence of a certain file, and create that file when you are done setting up). Then you only have to check one place (unless it's the cache dir, in which case you can't guarantee that the files will stick around forever).
If you have a lot of asset files, I would use a two-stage lookup: consult your downloaded image directory first (so you can override builtin assets, for example), then consult your assets directory. This is also flexible enough to allow you to make use of multiple storage locations should you find the need.

Categories

Resources