Take the 2-minute tour ×

Possible Duplicate:
What is Context in Android?

I would like to have an answer on this question Android - SharedPreferences with serializable object:

LocalPersistence LP=new LocalPersistence();
Asortiment=(Nomenklatura) LP.readObjectFromFile(???, filename);

But can't understand what to pass instead of Context context in main activity?

share|improve this question
I try to pas it, but I get message: Application has stopped unexpectedly for: FileInputStream fileIn = context.getApplicationContext().openFileInput(filename); Maybe filename is wrong –  user1884872 Jan 3 '13 at 14:47
Post a stack trace, or at least the Exception –  Bart Friederichs Jan 3 '13 at 14:57
add comment

marked as duplicate by Tomik, Shashank Kadne, Damon, Matthieu, Ram kiran Jan 4 '13 at 3:40


1 Answer

up vote 1 down vote accepted

If you are in the Activity, you can pass this. Otherwise (for example if you are inside another class), you can always use MyActivity.this to get a app-wide available reference to the activity object (there is always only one).

share|improve this answer
add comment
