Hrk Hrk - 1 year ago 196
Android Question

How do I generate XML resources at runtime on Android?

I have different strings.xml files in my resources folders (values, values_fr, values_de...), and I would like to load additional translations during runtime. Is it possible to add the new strings to those files even if it has already been compiled? Or is there a workaround?

Answer Source

The simple answer is that you can't. You can't modify hard-coded stuff into APK resources.

But there are some options. For instance you can:

  • Let's say read a resource, modify it, and save it into another external folder (SD card or so)
  • Create AssetManager over those file(s)
  • Then create Resources which can be later used as ordinary Android resource stored in APK
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download