user5307594
user5307594

Reputation:

Android write to internal storage issue

I've got an issue with writing to internal storage. I have read a lot of tutorials, but everywhere is this: FileOutputStream fOut = openFileOutput(FILENAME, Context.MODE_PRIVATE); But it says that openFileOutput is not a method.

Upvotes: 1

Views: 115

Answers (1)

Evgeniy Strepetov
Evgeniy Strepetov

Reputation: 684

openFileOutput is a method of Context class https://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String,%20int)

Activity is a subclass of Context. So if you are trying to call this method in Activity, it should be supported. If you trying to call it in some custom class, you should pass to it some instance of Context class or subclass (for example Activity instance)

Upvotes: 1

Related Questions