I would like to call method1 from another class, but how can i use getActivity() in a static method? I only found examples for FragmentActivity or other types. I am sorry if this question already got answered somewhere else, but i could not find anything that i could implement in my code. Any help is appreciated.
public class Tab1 extends Fragment {
public static String readFromFileKurs(Context ctx) {
        ret = "";
        try {
            InputStream inputStream = ctx.openFileInput("configkurs.txt");
            if ( inputStream != null ) {
                InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                String receiveString = "";
                StringBuilder stringBuilder = new StringBuilder();
                while ( (receiveString = bufferedReader.readLine()) != null ) {
                    stringBuilder.append(receiveString);
                }
                inputStream.close();
                ret = stringBuilder.toString();
            }
        }
        catch (FileNotFoundException e) {
            Log.e("login activity", "File not found: " + e.toString());
        } catch (IOException e) {
            Log.e("login activity", "Can not read file: " + e.toString());
        }
        return ret;
    }
public static void method1(){
temp = readFromFile(getActivity());
}
}
 
     
    