The method OpenFileOutput() is undefined ! The method OpenFileOutput() is undefined ! android android

The method OpenFileOutput() is undefined !


Those are methods defined on the Context class, not methods defined in your class. When your code was part of an Activity, it could use a convenience method openFileInput() in its Activity base class to access the underlying Context.getApplicationContext().openFileInput() (and similarly for openFileOutput()).

Now you'll have to replace those with the direct calls to the underlying Context methods.


Replace

FileOutputStream fos = openFileOutput(Adress, Context.MODE_PRIVATE);

with below line

FileOutputStream fos = getApplicationContext().openFileOutput(filename, getActivity().MODE_PRIVATE);

If used inside Fragment

FileOutputStream fos =getActivity().openFileOutput(filename, getActivity().MODE_PRIVATE);