I have some configuration files that should be editable. I need to add all of them to the project before creating the .apk file. Also they should remain private to the application, then I guess that they should go in the Internal Storage.
Is it possible to do? In which folder should I put them.
One of the solutions I found is to add them to assets and move to Internal Storage in the first run, but files size is too big to duplicate the memory.
Thank you.
I have some configuration files that should be editable. I need to add all of them to the project before creating the .apk file.
By default, those two concepts are mutually exclusive. Files that are in your APK (e.g., in assets/) cannot be edited.
One of the solutions I found is to add them to assets and move to Internal Storage in the first run, but files size is too big to duplicate the memory.
Then make smaller files. This is your only option that even comes close to meeting your requirements.
Related
I am trying to package /somewhere/lib/python3.x inside APK's lib folder like jniLibs. But it contains *.py, *.pyc and other files. I have asked another question, but there is no answer. So this is a general question: do you ever used or developed any plugins that embed non-standard files in APK instead of using assets?
How would you access those files? I mean you could put them in the apk, an apk is just a zip file. But the system won't unpack them for you, and at runtime you won't be able to access the apk file itself (installation unzips your file and deletes the apk). You might be able to fool it into doing so by putting it with the jni libs and hoping it doesn't look at extention, but it seem like a bad idea.
However its not uncommon for an app to take its assets and write them to the filesystem on first boot. In fact its fairly common to do this with updatable assets (you'd then just download new versions on top of them, but you can use the old versions to not need an immediate network connection). This would probably work for you. Just make your initial activity a splash screen, and have it do the copy from assets to files in the background while the splash is up.
I read on how to reduce SKMaps.zip file size by deleting some of the files. Regarding to the same I need more information.
I deleted grayscalestyle, outdoorstyle and nightstyle folders and all the contents of sound_files (Maps/Advisor/en) directory.
There are two folders .Common and .Routing, .Common is of 28.5MB!! Are all the contents of this directory required? I tried deleting these two folders completely which resulted in map crash. If can be deleted which all files in these two folders can be deleted?
PreInstalledMaps directory is >10MB, which files can be deleted from this? I don't have preinstalled maps feature at all.
I read this, I need much more clarifications WRT other directories. Please let me know which all directories/files can be deleted as I need to reduce final APK size as much as possible.
No Routing/directions in this app.
The common directory contains files shared by all styles - the biggest file in there is the fonts file.
The fonts file provides all the required glyphs for all the character sets that the SDK supports (latin, arabic, cyrillic, chinese, etc.) - for the time being you cannot delete anything in there. In a future update there will be the option to use system fonts (instead of a fonts file).
The only workaround (at this time) would be to separate this file from the bundle, host it on your servers and download it before starting the SDK - this will be a one time operation - it will reduces the initial app size but it will increase the startup time (the first time).
The PreInstalledMaps folder - you can delete the meta folder.
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.
What is the best way to store sound files (ogg) that are distributed with the app and updated at runtime?
I am developing an app that includes a default set of sounds as resources (res/raw/*.ogg). These work fine for the defaults but I want the user to be able to update the set of sounds with recorded sounds and downloads from the Internet. The problem is that the resources are read-only and, I think, assets are also read-only. I don't know how to include files in the project so they can be updated at runtime.
I can have the defaults as resources and files added at runtime on internal storage or SD Card, but I would prefer to have all the files in one place with a single interface for accessing them. Is there a way to include files in the project so they are written to internal storage or SD Card when the app is installed? Or is there a better place to put the files?
Put your files in /asset directory when packaging the .apk file. At runtime copy those files in application's internal storage /data/data/<application_package_name>/files (If files are not to much sized, It useful when device has no external storage included). Also update the files in same location..
I making an application with phonegap/cordova where I need to keep a lot of files up to date. Some files (mainly images) will need to be erased in time, and some new ones will get downloaded. The thing is, in Android, to manipulate those files, it seems I need to have them on the sdcard; so I copy the files the app starts with from my assets folder to the sdcard. It just seems like a waste of memory space.
Do you know if is there anyway I can start with the app having those files the app starts with already inside the sdcard? or at least somewhere I can delete them later?
Thank you.
Files that are delivered to the device as part of your APK will be stored in a form that cannot be modified by your application (other than by updating to a new version of the apk).
If you copy the files out of the APK into the private internal storage area or the external storage area, those copies can be modified, but the originals inside the apk will remain.
The most efficient solution may be to not put these files in your apk, but have your app instead download them separately on the first run, using whatever mechanism you wanted to use to change them in the future.
(Some people object to this feeling that such files are less secure against unauthorized use, but as the contents of an .apk are trivial to extract this is not a strong argument. Needing to maintain a server to download from is a slightly more substantial objection.)
You do not need to store the files on the SD Card. Each app has its own internal storage that is not accessible by any other apps. For more information see the official docs: http://developer.android.com/guide/topics/data/data-storage.html