I am adding points to the map, their location I am saving into the databse. When I click on a previously added point on the map, I want to perform SQLite query, whethere I have clicked on some point. Obviously, you are not 100% correct when clicking on item on display. I have invented a squared area, which will accept click as a it is a desired point (more info is seen on the image). I have divided this area to four quadrants for SQlite query – if it is accepted as a Point selection, I have to put my finger only and only in one of those quadrants.
I am using SQL statement for figuring out, if I have clicked on the point or not:
cursor=db.query("points_details2", null ,"(location_X <="+cXplus+" AND location_Y >="+cYminus+") OR (location_X >="+cXminus+" AND location_Y >="+cYminus+") OR (location_X <="+cXplus+" AND location_Y <="+cYplus+") OR (location_X >="+cXminus+" AND location_Y <="+cYplus+")", null, null, null, null);
Log.d("POINT", "Cursor "+cursor.getColumnName(0));
cursor.moveToFirst();
while (cursor.isAfterLast() == false) {
Log.d("POINT","data is: "+cursor.getInt(0)+", "+cursor.getString(1)+", "+cursor.getString(2)+", "+cursor.getDouble(3)+", "+cursor.getDouble(4));
cursor.moveToNext();
}
cursor.close();
And the boundaries are specified as:
double cXplus=coord_X+5;
double cXminus=coord_X-5;
double cYplus=coord_Y+5;
double cYminus=coord_Y-5;
So here is the boundary 5, coord_X and coord_Y are coordinates of my screen click with my finger.
Here is the thing – Am I using bad approach? This SQL statement I have provided is not working, and I don’t know why. Can anyone help me in this case? Thanks
They should all be
AND! You want the point to be inside ALL four corners of the square.i.e.