Externally download the file Strings.xml? - android

Hey, I have a lot of strings data, so I put them into Strings.xml..
The problem is that String.xml now is 5 mb big! So the .apk becomes big.. If I make on the first lunch of my app download the Strings.xml from a server, is it possible to replace a blank one that I put into the .apk with the one that I download after the app installation? Or is it bad to have the Strings.xml so big?

Resources are read-only, so you can't replace them.
If you're not using the localization features (-en, -it, -de ...) and you can make your app download only the strings you need (provided you don't need always all of them), I would do that if it's worth it.
However, even if 5mb for a text file is a lot, I don't know if there are actual drawbacks, and in the end it will get compressed when in the apk.

Short answer: you can't replace a file which is embedded into the apk,
also note that during the building stage, each xmls are converted into a
binary representation.
Since I don't know nothing about your app I can't tell if is bad to have
a so big string.xml. maybe I'll take a look at the performance and at the
memory consumption.

Related

Android App Bundle base raw resources how to prevent it for pack up into base apk

Maybe the title is a little bit confusing , but I will try to explain
I have an app with a lot of audio files keep in raw resource folder like this
so those audio files are big , and language specific. I'm using app bundle , and its force me to have this base raw folder.
So now every apk generated for specific language has both base and language specific raws, and my apk is twice as big as it should be
Is there a way to prevent adding raw-s from base folder to final apk ?
regards
Wojtek
EDIT: I found cheat solution :/ I don't like it but it seems to work.
I have added a resConfig for all suported languages and in base raw folder I've added a dummy empty files 1 KB. Tested on different languages and it works, but it is not the kind of solution I'm feeling fine with :/
You can use language targeted assets. It's not documented as not explicitly supported but it should work.
Instead of putting your files at the root of your APK, put them under:
assets/audio#lang_fr/a1.mp3
assets/audio#lang_fr/a2.mp3
...
assets/audio#lang_es/a1.mp3
assets/audio#lang_es/a2.mp3
...
assets/audio/a1.mp3
assets/audio/a2.mp3
Since it's not documented, it's possible that the behaviour changes without notice though, but I thought I'd mention it in case you want to try it out.

Update resource from external API android

In my app I want to update the strings.xml file at runtime. So the idea is to download the content from an external API and then update the strings.xml file. Does anybody had any past working experience on this or any idea how to achieve this goal will be a great help!!
You cannot modify resources at runtime. You are welcome to ship a new APK that contains the new resources, though.
You are also welcome to download files from the Internet, parse them, and use their contents. However, you have no means of using them literally as string resources. They will just be strings (or whatever else you parse from the file).
You can't do that. If you ever happen to add values to the strings.xml at runtime, their ids won't be generated in the R.class, you can alternatively save those strings to another file on the phone (database file, json file, xml, etc.).

Can I change a string in the strings resource file to one from array in an activity?

Been having a little bit of trouble with this. Googled about and I can't really find anything. Saw a few things about setting text but I don't think that affects the string resource file or at least I can't make it affect the resource file. Help please!
No, you can't modify apk at the runtime. If you don't own source code, you can pull apk file to the computer and decompile it by using APKTool, for example. If you are working with data you get from internet/user, it should be kept inside DBs, files, whatever. In other words in internal or external storage. Please take a look on storage options you can use http://developer.android.com/guide/topics/data/data-storage.html

Max number of file packaged with an app

Bit of an odd question but..
I am currently building an app, it will essentailly be a hotel listings directory with a few frills.
Having never made an app like this before I have suddenly found my self with the following question but cannot find the answer...
Is the there a limit the number of file you can package the app with, ie submit to itunes...
The reason I ask is potentially I will want to submit my app with a minimum 700+ images each in their own directory resulting in 1400+ files (assuming a directory is a file). I can get the size of the images to fit the 'over the air' max app download size.. but cannot find if there is a limit ot the number of files you can submit...
There is no as such limit for the number of files to be uploaded. However, as you mentioned it would be better to download your files from the app after installation.
This would help you reduce the binary size.
This is for iOS.
Your app usually comes in one .apk file. Your resources included. Link: https://en.wikipedia.org/wiki/APK_%28file_format%29 So its size is what matters.
You may want to double check the architecture of your app, it sounds like you want a webservice.

How to upload XML file data in android emulator of more than 1.2Mb

I want to load a single XML file of 1.2Mb in android through assets folder as raw file. I heard that there is a limitation in android of 1Mb for a single xml file. How can I get rid of it? Is there any option to overcome this issue?
First, don't use assets/ for XML, if your intention is to use it in your application. Use res/xml/, as parsing will be about ten times faster, and will also take up less space.
Then, I would simply try it with your file and see if it blows up. I know there is a limit, but I do not know what the threshold size is.
If it blows up, you will either need to split it into multiple files (each with a subset of your data), or not package it with the application, instead downloading it from a server on first run of your appl.

Categories

Resources