I´m writing an android application that receives gps data from a MySQL database, such as gps coordinates, and then tells the shows the user these coordinates on Google maps.
I have a SQLite database that stores the Latitude and Longitude values locally, and my question is how I can retrieve these values in on SQLite query and return the values in to two strings.
This is my take on the problem.
DbAdapter class “Databasehandler”:
public Cursor getLatLng(){
SQLiteDatabase db = this.getReadableDatabase();
return db.rawQuery("SELECT * FROM " + TABLE_CARCOORD + " WHERE name = " + CAR_KEY_NAME , null);
}
Class “UserFunction”:
public String getCoords(Context context, String lat, String lng) {
DatabaseHandler db = new DatabaseHandler(context);
Cursor cursor = db.getLatLng();
if (cursor.moveToFirst()){
lat = cursor.getString(cursor.getColumnIndex("lat"));
lng = cursor.getString(cursor.getColumnIndex("lng"));
}
return lat, lng;
}
It gives me error when i try to return two values. Anyone that haves any suggestions?
I’m a beginner at android programming and Java in general, so please forgive me if there is an obvious answer to this.
instead of returning String change return type of method to
ArrayListor String Array to return more then one value from method as :and in other call retrieve these values as :