Reputation: 670
PrintWriter p;
try {
p = new PrintWriter(new FileWriter("xp.mdb"));
} catch (FileNotFoundException e) {
return;
} catch (IOException e) {
return;
}
p.println("mytext");
p.close();
I'm new to Android programming and don't quite understand how writing to files work. I want to create a new file and write some text to it. The above code works on Windows but on Android I just keep getting FileNotFoundException.
How can I make it create the file if it doesn't exist?
Upvotes: 0
Views: 93
Reputation: 1006819
You need to put the file in internal storage, external storage, or (on Android 4.4+) removable storage. Passing a bare filename does not work on Android.
Upvotes: 3