how to fetch the date and time and save it in textfile android? -


i fetching gps location once in half hour , displaying in textview saving values passed in textview sdcard gpsdata.txt file, using below code here have save time , date , numbered.


  • now gps location in txt file :

13.01471695,80.1469223 13.01471695,
80.1469223 13.01471695,80.1469223
13.01471695,80.1469223

  • but need this:

1)13.01471695,80.1469223 time:12 30pm date:1/1/2013
2)13.01471670,80.1469260 time:12 45pm date:1/1/2013

public void appenddata(string text) {           file datafile = new file(environment.getexternalstoragedirectory() + "/sundth/gpsdata.txt");    if (!datafile.exists())    {       try       {          datafile.createnewfile();       }        catch (ioexception e)       {          // todo auto-generated catch block          e.printstacktrace();       }    }    try    {       //bufferedwriter performance, true set append file flag       bufferedwriter buf = new bufferedwriter(new filewriter(datafile, true));        buf.append(text);       buf.newline();       buf.close();    }    catch (ioexception e)    {       // todo auto-generated catch block       e.printstacktrace();    } } 

thank you.

before line buf.append(text); add lines of code;

simpledateformat sdf = new simpledateformat("hh:mm dd/mm/yyyy"); string currentdateandtime = sdf.format(new date()); text+=" "+currentdateandtime; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -