donfuxx is right; FileRead.getContext()
is null.
However we can still get context! Pass it in as a parameter for readRawTextFile()
.
So it becomes:
public static String readRawTextFile(Context context);
then change the FileRead.getContext()
to
inputStream = context.getResources().openRawResource(R.raw.plik);
then change your method call to this:
String articleString = FileRead.readRawTextFile(context);
replacing context with
- this or this.getContext() - if you are calling method within an activity
- getActivity() - if you calling this within a fragment (Beware: do a null check before using. getActivity() will return null if the fragment is not attached to an activity)
- _varWithContextIn - if you are calling this within say an setOnClickListener where "this" becomes the onClickListener you are creating.