Your code seem perfect, I assume you are getting Null because there is no previous GPS value in your device. Do this,
Load the application in your device, move to open sky, run the application, wait for 2 minutes. Come back to office inside, and then execute above code
OR
Run the application in open sky..