user3489753
user3489753

Reputation: 1

Issue with Context (Android ADT)

I'm trying to create a shared preferences to save TextFields in my app. Whenever I try to use context it will not allow me to call getApplicationContext() it gives me the error ("No method Defined for this class"). Whenever I create a Context defined as null it gives me a time error.

My code is:

Context context = getApplicationContext();
SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);

Upvotes: 0

Views: 60

Answers (1)

darnmason
darnmason

Reputation: 2732

Where are you executing this code? If in an Activity you can use this wherever you need to pass a Context as Activity extends Context.

Upvotes: 1

Related Questions