程序的功能是读取GPS信息并在google map上显示出来,然后每隔固定的时间将实时GPS数据存入本地的记事本中,包括保存数据的时间,经纬度。在地图上显示这部分已经做出来了,但是请问如何讲GPS数据存入本地记事本中呢,以下是小弟的代码,请问应该用什么语句插入到什么地方?谢谢。public class CurrentLocationWithMap extends MapActivity {

    MapView map;
    
    MapController ctrlMap;
    Button inBtn;
    Button outBtn;
    ToggleButton switchMap; 
    
    @Override
protected boolean isRouteDisplayed() {
return false;
}

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        map = (MapView)findViewById(R.id.myMapView); 
        List<Overlay> overlays = map.getOverlays();
        MyLocationOverlay myLocation = new MyLocationOverlay(this,map);
        myLocation.enableMyLocation();
        overlays.add(myLocation);
        
        ctrlMap = map.getController();
        inBtn = (Button)findViewById(R.id.in);
        outBtn = (Button)findViewById(R.id.out);
        switchMap = (ToggleButton)findViewById(R.id.switchMap);
        
        OnClickListener listener = new OnClickListener() {
            public void onClick(View v) {
                switch (v.getId()) {
                case R.id.in:
                    ctrlMap.zoomIn();
                    break;
                case R.id.out:
                    ctrlMap.zoomOut();
                    break;
                default:
                    break;
                }
            }
        };
        inBtn.setOnClickListener(listener);
        outBtn.setOnClickListener(listener);
        
        //=======================================
        
        switchMap.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton cBtn, boolean isChecked) {
                if (isChecked == true) {
                    map.setSatellite(true);
                } else {
                    map.setSatellite(false);
                }
            }
        });
        
        LocationManager locationManager;
        String context = Context.LOCATION_SERVICE;
        locationManager = (LocationManager)getSystemService(context);
        //String provider = LocationManager.GPS_PROVIDER;
        
        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        String provider = locationManager.getBestProvider(criteria, true);
        
        Location location = locationManager.getLastKnownLocation(provider);
        updateWithNewLocation(location);
        locationManager.requestLocationUpdates(provider, 30000, 10,
         locationListener);
    }
   private final LocationListener locationListener = new LocationListener() {
     public void onLocationChanged(Location location) {
     updateWithNewLocation(location);
          }
     public void onProviderDisabled(String provider){
     updateWithNewLocation(null);
     }
     public void onProviderEnabled(String provider){ }
     public void onStatusChanged(String provider, int status,
     Bundle extras){ }
    };
    private void updateWithNewLocation(Location location) {
     String latLongString;
     TextView myLocationText;
     myLocationText = (TextView)findViewById(R.id.myLocationText);
     if (location != null) {
         double lat = location.getLatitude();
         double lng = location.getLongitude();
         latLongString = "纬度:" + lat + "\n经度:" + lng;
         
         ctrlMap.animateTo(new GeoPoint((int)(lat*1E6),(int)(lng*1E6)));
     } else {
         latLongString = "无法获取地理信息";
     }
     myLocationText.setText("您当前的位置是:\n" +
     latLongString);
        
    }
}

解决方案 »

  1.   

    gps数据可以得到吧。
    然后就是存储的问题啦。不知道我理解的对不。
    给你存储数据的代码。希望有帮助。private   void   ReadFile() 

    string   filePath   =   Application.StartupPath   +   @ "\time.dat "; 
      if(File.Exists(filePath)) 
      { 
        StreamReader   srReadLine   =   new   StreamReader( 
    (System.IO.Stream)File.OpenRead(filePath),System.Text.Encoding.UTF8); 
        srReadLine.BaseStream.Seek(0,   SeekOrigin.Begin); 
        string   strToday     =   srReadLine.ReadLine(); 
        string   strMonth   =   srReadLine.ReadLine(); 
        srReadLine.Close(); 
        srReadLine   =   null; 
      } 

    private   void   WirteFile() 

    string   filePath   =   Application.StartupPath   +   @ "\time.dat "; 
    FileStream   fout   =   new   FileStream(filePath,FileMode.Create   ); 
    StreamWriter   fstr   =   new   StreamWriter(fout); 
    fstr.WriteLine(sbDay.ToString()); 
    fstr.WriteLine(sbMonth.ToString()); 
    fstr.Close(); 
    fstr   =   null; 
    fout   =   null; 
    }
      

  2.   

    此处用JAVA的输入输出流,编辑成文件发送到服务器制定文件里。