mercredi 30 mars 2016

How to display all lat values from this

I am retrieving latitude data from an SQLite Database.

I have a table filled with longitude and latitude values.

My query is:

 public Cursor fetchAllCountries() {
    SQLiteDatabase db=this.getReadableDatabase();
    String SelectQuery="select * from "+ TABLE_NAME;
    Cursor mCursor = db.rawQuery(SelectQuery,null);
    if (mCursor != null) {
        mCursor.moveToFirst();
    }
    return mCursor;
}

My MainActivity.java contains:

Cursor cursor = myDB.fetchAllCountries();

/* for (int i=0;i<list.size();i++) {
    double data=list.get(i);
    System.out.println(data + " ");
}*/

if (cursor.moveToFirst()) {
    do {
        double data = cursor.getDouble(cursor.getColumnIndex("lat"));
        System.out.println(data + " ");
    } while(cursor.moveToNext());
}

Aucun commentaire:

Enregistrer un commentaire