Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which data type to store a longitude and a latitude in a SQLite database?

I created a table with fields map_latitude and map_longitude in Sqlite Data Base with data type REAL.

But when I retrieved data from the database in Toast Message I see it with only zero decimal point.

for example:

15.31894  
store as 15.0  

how can I solve this?

like image 881
Mokhtar Ghaleb Avatar asked Oct 13 '17 14:10

Mokhtar Ghaleb


People also ask

Which datatype is used for latitude and longitude?

precision you should use DECIMAL . Latitudes range from -90 to +90 (degrees), so DECIMAL(10,8) is ok for that, but longitudes range from -180 to +180 (degrees) so you need DECIMAL(11,8) .

How do you store latitude and longitude in a database?

Storing Latitude & Longitude data as Floats or Decimal This is one of the most fundamental ways of storing geocoordinate data. Latitude & longitude values can be represented & stored in a SQL database using decimal points (Decimal degrees) rather than degrees (or Degrees Minutes Seconds).

Which datatype is used to store string in SQLite database?

TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).

What are the data types in SQLite?

SQLite only has four primitive data types: INTEGER, REAL, TEXT, and BLOB. APIs that return database values as an object will only ever return one of these four types.


1 Answers

You should use Data-Type REAL.

The value is a floating point value, stored as an 8-byte IEEE floating point number.

Safe Approach is -> Using TEXT

like image 110
IntelliJ Amiya Avatar answered Oct 08 '22 21:10

IntelliJ Amiya