Code example for SharedPreferences.Editor: Saving app preferences

Methods: commit, putFloat

        if (start) { 
            //save location in shared preferences for Event class to access when it is created. 
            Context context = getApplicationContext(); 
            SharedPreferences location = context.getSharedPreferences("location", Context.MODE_PRIVATE); 
            Editor locationEditor = location.edit(); 
            locationEditor.putFloat("lat", (float) l.getLatitude()); 
            locationEditor.putFloat("lon", (float) l.getLongitude()); 
            //Send a broadcast message with location change details 
            Intent i = new Intent("com.csis247.theApp.customLocationUpdate"); 
            i.putExtra("lat", l.getLatitude()); 
            i.putExtra("lon", l.getLongitude()); 
            start = false; 
        /* update the latest network provided location and start waiting for 15 seconds 
         * for the GPS to provide a location update. After 15 seconds supply a dummy gps point