0

I'm trying to create a way to get input from a user and save the string in the string.xml, so that when I launch my Application again, it will be there. Can I use the string.xml or do I have to save it another way?

2 Answers 2

3

Can I use the string.xml or do I have to save it another way?

You will have to do something different. The resources can't be changed after it has been compiled.

Have a look at Storage Options to see which way is best for you. The best way will be determined by things such as the type and amount of data you will be storing.

The link I posted sums it up pretty well then you can dig into the structures that you think might work best for your situation. From the link:

Shared Preferences Store private primitive data in key-value pairs.

Internal Storage Store private data on the device memory.

External Storage Store public data on the shared external storage.

SQLite Databases Store structured data in a private database. Network Connection Store data on the web with your own network server.

Sign up to request clarification or add additional context in comments.

1 Comment

If it's a lot, then use a db.
0

in order to save your strings you can use SharedPreferences

to save your data

SharedPreferences pos;
public String fileName = "file";

pos = getSharedPreferences(fileName, 0);
SharedPreferences.Editor editor = pos.edit();
editor.putString("pwd","your string");      
editor.commit();

to get your data

pos = getSharedPreferences(fileName, 0);
String data = pos.getString("pwd", "");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.