The problem is that I call the selector from the cursor to make information output from the database, but for some reason when I try to check how it works, it does nothing. I select a parameter from the list, press, in the function I pass the id and in theory should derive the parameters from this id, but it does nothing.

Aydishniki everything is in order, if you delete it deletes, if you change it changes, but here it is a dilemma, does not want to withdraw. I convey the position correctly so that everything is supposed to work.

public static void shareData(Context context, long id) { try { DatabaseOpenHelper dbhelper = new DatabaseOpenHelper(context); SQLiteDatabase sqliteDB = dbhelper.getWritableDatabase(); int countRows = -1; String query = String.format("SELECT * FROM "+ Coords.TABLE_NAME + " WHERE " + BaseColumns._ID + " = " + id); Cursor cursor = sqliteDB.rawQuery(query, null); if (cursor.moveToFirst()) { countRows = cursor.getInt(0); if (LOGV) { Log.v(TAG, "Count in Coords table" + String.valueOf(countRows)); } while(cursor.moveToNext()) { float lat = cursor.getFloat(cursor.getColumnIndexOrThrow(Coords.CoordsColumns.LATITUDE)); float lng = cursor.getFloat(cursor.getColumnIndexOrThrow(Coords.CoordsColumns.LONGITUDE)); String name = cursor.getString(cursor.getColumnIndexOrThrow(Coords.CoordsColumns.COMMENT)); Log.v("","" + lat + " " + lng + " " + name); } } cursor.close(); sqliteDB.close(); dbhelper.close(); } catch (SQLiteException e) { Log.e(TAG, "Failed open database. ", e); } catch (SQLException e) { Log.e(TAG, "Failed to update Coords. ", e); } } 
  • @dajver, Looks like it helped a lot if you rewarded me so generously :-) Tell me what is the result? Skip line, order, or both? - Chad

1 answer 1

Do you have the first field in the table or countRows? and how do you determine that the first record always contains it?

and you code cursor.moveToFirst() and while(cursor.moveToNext()) explicitly skip the first line from the request. Maybe this is the case? If your structure depends on the order of the lines, then you obviously need to add order by to the request.