Avatar of shahjagat
shahjagatFlag for United States of America asked on

Android GPS Location Without Internet

I want to develop an Application which will store the Longitude and Latitude of
an Android device into device internal database, Using Device's GPS Chip and Not using Internet at all.

Can some one provide me the source code for the same.

Avatar of undefined
Last Comment

8/22/2022 - Mon

Hello shahjagat,

While I won't provide you with a fully functional example application, I can show you some useful links that you could use in order to achieve your goal:

- Here is how to create a database for your android application
- Here is how to get your GPS coordinates

Now you should be able to do your application just by combining those two pieces of information (creating your own DB application + getting your GPS coordinates + saving your coordinates into your database). As you can see, it doesn't implies using internet connection at all.

Good luck!
Chris Harte

In the tutorial on gps replace the line

provider = locationManager.getBestProvider(criteria, false);


provider = LocationManager.GPS_PROVIDER;

This will force the activity to use gps rather than network. In my experience android always defaults to 'network' even when there is no network connectivity.

Thanks Argenti,


I am new android developer

I am using below code, but it does not return latitude and longitude when internet is OFF,
I also want to calculate speed, distance covered and odometer reading ,
My device will be inside the bus and in the region where there is no internet.

Any help will be appreciated,  

My code
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (locationManager != null)
             location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if (location != null) {
                  latitude = location.getLatitude();
                  longitude = location.getLongitude();
Your help has saved me hundreds of hours of internet surfing.
Chris Harte

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks for all answers