private static String geturl() {
Context applicationContext = configActivity.getContextOfApplication();
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
SharedPreferences prefs =applicationContext.getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String url = prefs.getString("url", "No name defined");
return url;
}
This method is in a non-activity class i tried to have my string from a non-activity class i tried to do like someone say there :Android - How to use SharedPreferences in non-Activity class?
but i have this error :
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference