change String.xml by the java class

Asked

Viewed 224 times

0

Hi, I was wondering if it is possible to modify a String from the values folder by clicking a button.

these are the String.xml

<string name="app_name">FC MANAGER</string>
<string name="goleiro_1">1 Diego Alves</string>
<string name="goleiro_2">37 César</string>
<string name="zagueiro_1">15 Rever</string>
<string name="zagueiro_2">4 Juan</string>
<string name="zagueiro_3">44 Rhodolfo</string>
<string name="zagueiro_4">43 Léo Duarte</string>
<string name="lateraldireito_1">2 Rodinei</string>
<string name="lateraldireito_2">21 Pará</string>
<string name="lateralesquerdo_1">6 Renê</string>
<string name="lateralesquerdo_2">13 Miguel Trauco</string>
<string name="volante_1">8 Cuéllar</string>
<string name="volante_2">14 Jonas</string>
<string name="volante_3">27 Romulo</string>
<string name="meiocampo_1">10 Diego</string>
<string name="meiocampo_2">7 Everton Ribeiro</string>
<string name="meiocampo_3">11 Lucas Paquetá</string>
<string name="meiocampo_4">18 Jean Lucas</string>
<string name="atacante_1">19 Henrique Dourado</string>
<string name="atacante_2">20 Vinicius Junior</string>
<string name="atacante_3">29 Lincoln</string>
<string name="atacante_4">23 Geuvânio</string>
<string name="tecnico">Barbieri</string>

I wanted to know if it is possible through a command in the java class to change a string that is selected.

  • 1

    Utilize Sharedpreferences instead of the file String.xml

1 answer

3

When you provide a value as a resource (Resource) it cannot be modified at runtime. For example, the images you have in your folder drawable cannot be modified at runtime and this applies to Strings.xml and the folder Values.

If you want a string modified at runtime, do not create it as a resource.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.