Click here to Skip to main content
15,917,060 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working GPS app and Ona click event I want to store the latitude and the longitude values in shared preferences with a name. Now when I use shared preferences the values are getting stored but if I run the app again the it is over written by new values.
I want all the values to remain in shared preference.
Can any one help?


C#
public void onClick(View v) {

     String etLocal =  customDialog_EditText.getText().toString();
     SharedPreferences sh1 = getSharedPreferences(MainActivity.stg, 0);
    String s1 = sh1.getString("latitude", "");
    String s2 = sh1.getString("longitude", "");
Posted

1 solution

Try this:
Java
SharedPreferences sh1 = getSharedPreferences(MainActivity.stg, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("latitude",yourLatitudeString);
editor.putString("longitude",yourLongitudeString);
editor.commit();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900