【发布时间】:2013-04-20 10:11:24
【问题描述】:
我每半小时获取一次 gps 位置并在 textview 中显示它,同时使用以下代码将 textview 中传递的值保存到 sdcard gpsdata.txt 文件,但在这里我必须保存它的时间和日期以及编号。
- 现在我在 txt 文件中得到这样的 gps 位置:
13.01471695,80.1469223 13.01471695,
80.1469223 13.01471695,80.1469223
13.01471695,80.1469223
- 但我需要这样:
1)13.01471695,80.1469223 时间:12 下午 30 点日期:2013 年 1 月 1 日
2)13.01471670,80.1469260 时间:12 下午 45 点日期:2013 年 1 月 1 日
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 for performance, true to set append to 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();
}
}
谢谢。
【问题讨论】:
标签: android date time gps location