I'm fetching data from database using arraylist, but some double values convert into round off values.
public ArrayList<HashMap<String, String>> getTrackList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
String selectQuery = "SELECT * FROM TRACK";
ArrayList<HashMap<String, String>> trackList = new ArrayList<HashMap<String, String>>();
trackList.clear();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
HashMap<String, String> track = new HashMap<String, String>();
track.put("LATITUDE", cursor.getString(cursor.getColumnIndex("LATITUDE")));
track.put("LONGITUDE", cursor.getString(cursor.getColumnIndex("LONGITUDE")));
track.put("DATE", cursor.getString(cursor.getColumnIndex("DATE")));
track.put("SPEED", cursor.getString(cursor.getColumnIndex("SPEED")));
track.put("ACCURACY", cursor.getString(cursor.getColumnIndex("ACCURACY")));
track.put("PROVIDER", cursor.getString(cursor.getColumnIndex("PROVIDER")));
track.put("DISTANCE", cursor.getString(cursor.getColumnIndex("DISTANCE")));
trackList.add(track);
} while (cursor.moveToNext());
}
jSon = new Gson().toJson(trackList);
cursor.close();
return trackList;
}
here latitude, longitude and distance are double values, distance is same as database, but latitude or longitude are not same, suppose latitude is 22.8569874 in database but it returns 22.857
Aucun commentaire:
Enregistrer un commentaire