I’m new in Andy world. I’m doing mine first app. GPS tracker.
I need to save coordinates + (time ,date) to file on SD.
Coordinates are easy, but Time & Date ( in SimpleDateFormat) make me a trouble.
write() method has problem with SDF. I’ve tried convert to string and many other things.
official error message is:
“The method write(byte[]) in the type FileOutputStream is not applicable for the arguments (String)”
FileOutputStream fos = openFileOutput("kris.txt", Context.MODE_PRIVATE);
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd' 'HH:mm:ss " );
String k = sdf.toString();
fos.write(k);
fos.flush();
fos.close();
As I understood you just need to change the method. To write strings to a file you need to use BufferedWrite or PrintWriter.
Try this:
(code from a java manual)