Because you are trying to write the file to root, you need to pass the file path to your file directory.
Example
String filePath = context.getFilesDir().getPath().toString() + "/fileName.txt";
File f = new File(filePath);
More Related Contents:
- Set ImageView width and height programmatically?
- What is sharedUserId in Android, and how is it used?
- Android Studio error: “Manifest merger failed: Apps targeting Android 12” [duplicate]
- How to fix INSTALL_PARSE_FAILED_MANIFEST_MALFORMED in my android application
- How do I detect the heap size usage of an android application
- How to speed up unzipping time in Java / Android?
- Using accelerometer, gyroscope and compass to calculate device’s movement in 3D world
- java.lang.arrayoutofboundexception length:10 index:10
- Https Connection Android
- One time login in app – FirebaseAuth
- Is it possible to declare a variable in Gradle usable in Java?
- Understand the R class in Android [duplicate]
- cannot resolve symbol ‘java.time.LocalDate’ error in android studio
- Place cursor at the end of text in EditText
- How to programmatically enable GPS in Android Cupcake
- Android heterogeneous gridview like pinterest? [closed]
- Which JDK version (Language Level) is required for Android Studio?
- Resize image to full width and fixed height with Picasso
- When is onAttach called during the Fragment LifeCycle? [duplicate]
- How can I start a new android activity using class name in a string?
- RxJava instead of AsyncTask?
- comparison of two Strings doesn’t work in android [duplicate]
- Navigation Drawer closes on click
- FATAL EXCEPTION: Firebase-Messaging-Intent-Handle — java.lang.NoClassDefFoundError
- Get the file size in android sdk?
- Convert colorPrimary to colorPrimaryDark (how much darker)
- Java Static Variable becomes null [duplicate]
- stringByEvaluatingJavascriptFromString (iOS method, what is Android equivalent?)
- java.lang.SecurityException: attempting to read gservices without permission
- How to execute web request in its own thread?