Save several variables in an EditText [closed]

-1

Hello, my problem lies in how to save different strings that are written in an Editview.

I can save a variable every time a button is pressed. But I do not know how to save another String in another variable, can anyone help me?

(Another question would be how to create variables in an automatic way without declaring them before)

    
asked by anonymous 27.09.2016 / 03:20

1 answer

1

To store several variables, you need a structure to add multiple variables.

If you know how many entries you have, you can use an Array:

String[] valores = new String[5] // 5 = o número de "gavetas" que seu Array terá

In this way you can access the content by doing valores[índice]

When you do not know how many entries you have, you can use a List of objects.

List<String> minhaLista = new ArrayList<>();

In this way, when you need to store a variable, use minhaLista.add("Minha String"); and to retrieve the value use minhaLista.get(índice)

    
27.09.2016 / 13:55