I want to add certains strings as resource in file "strings.xml".
I want to use ip1 and port1 as resources in "strings.xml" through java. Anyone know how to do ?
It is impossible to save or change values in strings.xml since it is a compiled resource. you can choose other ways to save datas, take a look at this:
https://developer.android.com/guide/topics/data/data-storage.html
strings.xml:
<resources>
<string name="ip">INSERT TEXT FOR IP HERE</string>
<string name="port">INSERT TEXT FOR PORT HERE</string>
</resources>
onCreate() within an Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("LOG_TAG", getString(R.string.ip));
Log.d("LOG_TAG", getString(R.string.port));
}
Let me know if this answers your question.