Hi guys,
I'm a bit of a newbie to Java and was wondering if someone here may be able to help.
I've had a few tries at typing out an explanation of what I mean and failed miserably so I will post the code
*/ public void onLocationChanged(Location location) { //Some non relevant code removed// SharedPreferences app_preferences_write = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor e = app_preferences_write.edit(); String latString = Double.toString(lat); String lngString = Double.toString(lng); e.putString("latitude", latString); e.putString("longitude", lngString); } public void savePosition() { e.commit(); }
My problem is that my object 'e' cannot be seen from savePosition() and I cannot commit in the onLocationChanged method as this would save the position every single time a new position is recorded.
Please can someone offer some advice?