Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6849803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:02:28+00:00 2026-05-27T01:02:28+00:00

I have a data table in my SQLite database with information about longitude, latitude

  • 0

I have a data table in my SQLite database with information about longitude, latitude and description. Given a certain location, I would like to get all the rows with a near distance (10 blocks) from that location.

This is how data is loaded:

values.put(LONGITUD_COLUMN,  (int) (-64.14802 * 1E6));
values.put(LATITUD_COLUMN, (int) (-31.36498 * 1E6));

So far this is what I have in code:

private int cuadras = (int)(-0.02 * 1E6) ; //10 blocks aprox, I guess
private int current_latitude = 0;
private int current_longitude = 0;

current_latitude and current_longitude, are loaded with (from LocationListener):

public void onLocationChanged(Location location) {
 current_latitude = (int) (location.getLatitude() * 1E6);
 current_longitude = (int) (location.getLongitude() * 1E6);
}

And the SQLite query is as follows:

String sql = "LATITUD_COLUMN > (" + (current_latitude + cuadras) + ") AND "
+ "LATITUD_COLUMN < (" + (current_latitude - cuadras) +") AND "
+ "LONGITUD_COLUMN > ("+ (current_longitude - cuadras) +") AND "
+ "LONGITUD_COLUMN < ("+ (current_longitude + cuadras) +")";

With this result:

LATITUD_COLUMN > (-31398170) AND LATITUD_COLUMN < (-31358170) AND LONGITUD_COLUMN > (-64132838) AND LONGITUD_COLUMN < (-64172838)

That query returns no results at all, my question is, how can I query the DataBase bringing all the locations near my current location?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:02:29+00:00Added an answer on May 27, 2026 at 1:02 am

    You appear to have your + and – mixed up:

    String sql = "LATITUD_COLUMN > (" + (current_latitude + cuadras) + ") AND "
    + "LATITUD_COLUMN < (" + (current_latitude - cuadras) +") AND "
    + "LONGITUD_COLUMN > ("+ (current_longitude - cuadras) +") AND "
    + "LONGITUD_COLUMN < ("+ (current_longitude + cuadras) +")";
    

    should be

    String sql = "LATITUD_COLUMN > (" + (current_latitude + cuadras) + ") AND "
    + "LATITUD_COLUMN < (" + (current_latitude - cuadras) +") AND "
    + "LONGITUD_COLUMN > ("+ (current_longitude + cuadras) +") AND "
    + "LONGITUD_COLUMN < ("+ (current_longitude - cuadras) +")";
    

    Note the swapped + and – in the last two lines.

    LONGITUD_COLUMN > (-64132838) AND LONGITUD_COLUMN < (-64172838) is always false. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python application. It has an SQLite database, full of data about
I have an sqlite database used to store information about backup jobs. Each run,
I have a table view which is populated from data from an SQLite database.
I have data in an SQLite table that looks like this: user_id event_date ----------
I have a DataTable which I want to save to a SQLite Database Table.
In my SQL Server database schema I have a data table with a date
I'm a bit confused on this. I have a data table structured like this:
I have data from a table in a database (string) that contain text and
I have inserted a lot of information into a SQlite database from my program.
I have an events app which gets events data from sqlite database and displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.