package org.bobstuff.bobball;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

/*
* simple global load and save using shared preferences
* you have to use setContext before using load or save
*/

public class Preferences extends Application{

    private static Context context;

    public static void setContext (Context ctxt)
    {
        context = ctxt;
    }

    public static String loadValue (String filename, String defaultValue) {
        SharedPreferences sharedPref = context.getSharedPreferences(filename, Context.MODE_PRIVATE);
        return sharedPref.getString (filename, defaultValue);
    }

    public static void saveValue (String filename, String value) {
        SharedPreferences sharedPref = context.getSharedPreferences(filename, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putString(filename, value);
        editor.commit();
    }
}

@@ -147,15 +147,8 @@
 ple 
-global 
 load
@@ -236,17 +236,75 @@
  or save
-%0A
+ in an activity%0A* you should use setContext in onCreate()%0A 
 */%0A%0Apubl
@@ -347,11 +347,68 @@
 tion
+ 
 %7B%0A%0A
+    private static SharedPreferences sharedPreferences;%0A
     
@@ -430,17 +430,20 @@
 Context 
-c
+appC
 ontext;%0A
@@ -487,17 +487,20 @@
 ontext c
-t
+onte
 xt)%0A    
@@ -509,17 +509,20 @@
         
-c
+appC
 ontext =
@@ -527,17 +527,20 @@
  = c
-t
+onte
 xt;%0A    
 %7D%0A%0A 
@@ -539,96 +539,13 @@
     
-%7D%0A%0A
     
-public static String loadValue (String filename, String defaultValue) %7B%0A        S
+s
 hare
@@ -553,35 +553,24 @@
 Preferences 
-sharedPref 
 = context.ge
@@ -584,32 +584,43 @@
 Preferences(
-filename
+%22sharedPreferences%22
 , Context.MO
@@ -640,64 +640,78 @@
     
+%7D%0A%0A
     
-return sharedPref.getString (filename, defaultValue)
+public static Context getContext () %7B%0A        return appContext
 ;%0A  
@@ -737,17 +737,19 @@
 tic 
-void save
+String load
 Valu
@@ -775,17 +775,24 @@
  String 
-v
+defaultV
 alue) %7B%0A
@@ -791,33 +791,40 @@
 alue) %7B%0A        
-S
+return s
 haredPreferences
@@ -827,83 +827,118 @@
 nces
- sharedPref = context.getSharedPreferences(filename, Context.MODE_PRIVATE);
+.getString (filename, defaultValue);%0A    %7D%0A%0A    public static void saveValue (String filename, String value) %7B
 %0A   
@@ -986,16 +986,23 @@
 aredPref
+erences
 .edit();

Update Preferences.java