Android Map overlay gives null pointer exception

192 Views Asked by At

I'm storing my latitude and longitude in content provider as a real type.

When I retrieve it using a cursor, I use .getDouble, which means now this is a double.

This method accepts lat and long in only int type newGeoPoint ( latitude, longitude )

When I tried converting lat and lon from double to int, I get java null pointer exception.

This is what I tried Int(latitude * 1E6); Can you shed some light on this?

Update

I converted this double value to string then passed it to toast, I'm getting the values in toast. Now the problem is, how do I convert from double to int with out losing the float part.

Thanks in advance!!

1

There are 1 best solutions below

0
On

Try casting after multiplying:

int longitude = (int) (longitudeInDouble * 1E6)