XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"

    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ZapisDo pliku"
        android:textSize="30dp"

         />


        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="TU WPIERDOL TEXT"
            android:id="@+id/INSERTTEXTHERE"

            />

    <Button
        android:id="@+id/ZAPISPLIKOWY"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ZapiszDOPLIKKKUUUUUU"/>


</LinearLayout>

JAVA

Button ZAPISPLIKOWY;
EditText INSERTTEXTHERE;

ZAPISPLIKOWY = findViewById(R.id.ZAPISPLIKOWY);
        INSERTTEXTHERE = findViewById(R.id.INSERTTEXTHERE);


        ZAPISPLIKOWY.setOnClickListener(view -> {
            String text = INSERTTEXTHERE.getText().toString();
            if(!text.isEmpty()){
                saveToFile(text);
            }
            else Toast.makeText(MainActivity.this,"sgiauheawguiawt", Toast.LENGTH_LONG);
        });




    }
    private void saveToFile(String text){
        FileOutputStream fos = null;
        try {
            String fileName = "dane.txt";
            fos = openFileOutput(fileName, MODE_PRIVATE);

        }
        catch (IOException e){
            Toast.makeText(MainActivity.this, "BŁĄD ZAPISU ZJEBIE!", Toast.LENGTH_LONG);
        }
    }
}