Is it possible in Android Studio to fill in the string.xml file programmatically using ArrayList, for example, or through an array?

I use the site parsing using the Jsoup library. Not how can I figure out how to fill in a string-array in the string.xml file, and is there such a possibility ???

  • 2
    write pragmai - Vladyslav Matviienko
  • one
    nothing can be written to strings.xml . There are no situations where this needs to be done. - Vladyslav Matviienko
  • I use the database to add a menu item to my favorites, respectively, I need to fill in the database, I take the lines for the database from the string. But often there is a lot of information and you need to manually constantly fill in the string, it would be easier to fill in the string automatically by parsing the site. - Artsait
  • one
    that is, you want to fill in the strings, and then immediately fill out the database from there? Why then strings at all? - Vladyslav Matviienko
  • one
    @metalurgus: Very simple: there is a code that reads from strings.xml, and the TC cannot adapt it. - VladD

2 answers 2

You do not need an intermediate step in writing data to application resources, especially since this is not possible. The resources are embedded in the application at the compilation stage and it is impossible to change them after the formation of the APK file (if you don’t use a completely true ultra-hardcore for a true ultra-hardcore).

If you want to fill out the database from the network then, having received the data from the network immediately and write them to the database without recording yet. So your application will always have fresh data and it’s not necessary to embed it in the application


If there is a possibility of problems with the site and / or you need to have an initial data set, then you can, without hesitation, build such a terrible crutch:

  1. Save the site code in the html file.
  2. Put this file in assets
  3. When you first run an application / missing data in the database / missing data from the network, set JSOUP to this file and write the result to the database.
  • Most likely you have to do it. But dependence on the site, I think is also not a good idea - Artsait
  • @Artsait, I just added a workaround for this. But he is not very handsome - YuriySpb
  • Thanks for the answer. I 'll try, maybe it is better - Artsait

Usually string-array in xml is filled in to parse into the collection and use, for example, in the adapter. I find it hard to imagine the purpose of this, but if such a need arose, you should reconsider the architecture of the application.

Somewhere else you have namudri.

  • The code has already so bothered that the devil himself will not understand)) Through the string I fill in the database, String, in turn, I want to fill in through the parsing site. Manually fill out a lot of time go. Maybe I did not quite understand the principle of the database. If you fill it in, how to publish it in the playmarket then ??? The contents of the database as I understand it is not generated with the application? - Artsait
  • I think in the play market it is not necessary to publish! - Vladimir VSeos