0
DecimalFormat df = new DecimalFormat("0.00");//if you want over four decimal places then do->"0.0000" in brackets

TextView lattextview=findViewById(R.id.lattextview);
TextView lontextview=findViewById(R.id.longtextview);
TextView alttextview=findViewById(R.id.alttextview);
TextView accuracytextview=findViewById(R.id.accuracytextview);
TextView addresstextview=findViewById(R.id.addresstextview);

String s1 = df.format(location.getLatitude());
String s2 = df.format(location.getLongitude());
String s3 = df.format(location.getAltitude());
String s4 = df.format(location.getAccuracy());
lattextview.setText("Latitude : "+s1);
lontextview.setText("Longitude : "+s2);
alttextview.setText("Altitude : "+s3);
accuracytextview.setText("Accuracy : "+s4);
user85421
  • 28,957
  • 10
  • 64
  • 87
Lavish Garg
  • 235
  • 2
  • 9
  • 1
    Please take the [tour] and use the [help] to familiarize yourself with how this site works. It’s perfectly fine to answer your own question, but you have to have a properly defined question and then add a separate answer. Also make sure the question has not been asked before. – Sami Kuhmonen Dec 28 '19 at 05:53
  • 2
    Does this answer your question? [How to round a number to n decimal places in Java](https://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java) – Kalpesh Kundanani Dec 28 '19 at 07:13

0 Answers0