Sunday, April 14, 2013

[android help] How to get a preference value into a static String variable?

java - How to get a preference value into a static String variable? - Stack Overflow




















"Cannot make a static reference to the non-static method getPreferences(int) from the type Activity" is the error in my case. 'TimeCardLogin' must be a static variable."



How to get a preference into a static String variable?



public class MyBaseURLContainer extends Activity {

public static String urlPref = "";

static String BASE_URL =
getPreferences(MODE_PRIVATE).getString("Name of variable",urlPref);

public static final String TimeCardLogin = BASE_URL + "/timecard";
}


















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










lang-java






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...