0

I have created a string in my main.java file as follows:

String message = "Current Location \nLongitude: "+ location.getLongitude()+"\nLatitude: "+ location.getLatitude();

I want to place this string in my strings.xml file.

This way I can display the value of the string at various places in my application.

I am not sure how to do this.

Any advice?

1
  • 3
    You cannot add items to your strings.xml (or anything else in the `res` folder) at runtime. If you want to store your string you'll have to do it in SharedPreferences, a Database, or in a File in internal/external storage. Commented Apr 17, 2013 at 14:10

1 Answer 1

1

You can edit your strings.xml only manually, not proramatically. If this is a dynamic string (and I assume it is), you will have to save it in a static variable for example, but can't write it into strings.xml.

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

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.