I made a library that I use across my app. I want it to access some settings that are stored in the shared preferences.
This is a shortened version of my library:
package com.android.foobar;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class Lib {
int now;
public Lib() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
now = settings.getInt("now", 435);
}
public int foo(){
return now;
}
}
I've been looking for an answer and experimenting, but I can't find a valid context to pass to getDefaultSharedPreferences(). Any ideas?