From what I can tell, the file does not exist. Try adding gpxfile.createNewFile ()
To get a little more information by creating an instance of File, do not create the file in the file system.
So this line -> File gpxfile = new file (path, file name);
not enough to create a file on the SD card. You have to follow him with
gpxfile.createNewFile (), which quotes the docs , says:
Atomically creates a new empty file, called this abstract empty file, if and only if the file with this name does not exist yet. Checking for a file and creating a file if it does not exist is one operation that is atomic with respect to all other file system actions that can affect the file.
source share