Android 无法将当前位置与数据库位置进行比较

Android 无法将当前位置与数据库位置进行比较,android,sqlite,gps,Android,Sqlite,Gps,我有一个正在运行的GPS服务,但我无法将我的当前位置与以前保存在数据库中的位置进行比较。应用程序运行正常,但当我取出onLocationChange()中编写的函数时,它会崩溃 功能是: LocationsDB db = new LocationsDB(this); Cursor c = db.getAllLocations(); c.moveToFirst(); while(c.moveToNext()) { arli

我有一个正在运行的GPS服务,但我无法将我的当前位置与以前保存在数据库中的位置进行比较。应用程序运行正常,但当我取出onLocationChange()中编写的函数时,它会崩溃

功能是:

LocationsDB db = new LocationsDB(this);
     Cursor c = db.getAllLocations();
     c.moveToFirst(); 

     while(c.moveToNext()) {             
        arlist.add(c.getString(c.getColumnIndex("FIELD_LNG")));
        arlistlat.add(c.getString(c.getColumnIndex("FIELD_LAT")));

        }

    for(int i=0;i<arlist.size();i++){
        if(arlist.get(i)==Double.toString(location.getLongitude()) && arlistlat.get(i)==Double.toString(location.getLatitude())){
            Intent myIntent=new Intent(GPSTracker.this,alarm.class);
            startActivity(myIntent);
        }
    }
LocationsDB db=新位置sdb(本);
游标c=db.getAllLocations();
c、 moveToFirst();
而(c.moveToNext()){
add(c.getString(c.getColumnIndex(“FIELD_LNG”));
add(c.getString(c.getColumnIndex(“FIELD_LAT”));
}

对于(int i=0;i不要使用
=
来比较
字符串

而是使用
.equal
.match

大概是这样的:

if(arlist.get(i)==Double.toString(location.getLongitude()) && arlistlat.get(i).equal(Double.toString(location.getLatitude()))){

使用
.equals()
而不是
=
来比较字符串。尝试仅在第一个位置更改时执行函数的第一部分(db查询和列表构造)