JosephTaylorC
Lurker
I am trying to make a simple use of SharedPreferences but I cannot seem to get this to work. It all works fine until the last statement. It is probably a simple error, but if anyone could help it would be great.
public class FiguringPrefsActivity extends Activity {
LinearLayout mainLayout;
SharedPreferences mySharedPreferences;
String filename;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainLayout = (LinearLayout)findViewById(R.layout.main);
Context context = getApplicationContext();
mySharedPreferences = context.getSharedPreferences(filename, Context.MODE_WORLD_READABLE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.putInt("COLOR", R.color.black);
editor.commit();
mainLayout.setBackgroundColor(mySharedPreferences.getInt("COLOR", R.color.white));
public class FiguringPrefsActivity extends Activity {
LinearLayout mainLayout;
SharedPreferences mySharedPreferences;
String filename;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainLayout = (LinearLayout)findViewById(R.layout.main);
Context context = getApplicationContext();
mySharedPreferences = context.getSharedPreferences(filename, Context.MODE_WORLD_READABLE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.putInt("COLOR", R.color.black);
editor.commit();
mainLayout.setBackgroundColor(mySharedPreferences.getInt("COLOR", R.color.white));