I am trying to save some data for a android game, but I cant create the file.
File file = new File(filename);
file.createNewFile();
or
File file = new File(filename);
file.mkdir();
What path should I set? The code above doesn’t work. I think I have the read/write correct, but I can’t make the file initially (and yes I have googled it)
It is a permanent file for the app.
If it’s a large file, you should create it on external storage (SD card). you can get the path to the ext. Storage by calling Environment.getExternalStorageDirectory(). so,
There is of course no permission on the external storage file system (because it’s a FAT file system). If you need the file to be private to your app, you can use Context.openFileOutput(),
This creates the file in a the app-specific data directory on internal storage. The file is private to the UID of your app, so it cannot be read by other applications.