As already mentioned, you need to use some persistent storage . Perhaps the database will be redundant in your particular case (if you just need to save a couple of long-latitude pairs), and the general settings will meet your needs. If you rarely need to read / store this data, then placing JSONArrayas a String for general settings will be the easiest (in terms of reading and retrieving data) solution:
SharedPreferences.Editor editor = getSharedPreferences("name", 0).edit();
JSONArray jsonArr = new JSONArray();
JSONObject json;
for (int i = 0; i < user_markers.size(); i++) {
json = new JSONObject();
json.put("lat", user_markers.get(i).getLat());
json.put("long", user_markers.get(i).getLong());
jsonArr.put(json);
}
editor.putString("markers", jsonArr.toString());
editor.commit();
If you need to read / store this data more often, you can assign identifiers / indices to separate SharedPreferences, but this may require a more complex extraction method. For instance:
SharedPreferences.Editor editor = getSharedPreferences("name", 0).edit();
int id;
for (int i = 0; i < user_markers.size(); i++) {
id = user_markers.get(i).getId();
editor.putString("markers_lat_" + id, user_markers.get(i).getLat());
editor.putString("markers_long_" + id, user_markers.get(i).getLong());
}
editor.commit();
In the end, you should consider using a database if you plan to store a large amount of data or data of a complex structure.