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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 HarteThaumaturgeCommented:
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.
shahjagatAuthor Commented:
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();
Chris HarteThaumaturgeCommented:
That is only part of your code and looks okay. Getting a signal from a satellite can be slow. Also, are you running this on an emulator or your device? Because the emulator does not get a satellite signal.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shahjagatAuthor Commented:
Thanks for all answers
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.