On Sat, 7 Feb 2015 11:27:59 +0530, Abdul Aziz <abduldblog...@gmail.com> wrote:
> Hi there! > I hope you are well! > > Recently I was working on project based on Android Sensors and encountered > a bug in sqlite db, situation was this: > I was setting there three values x,y,z as FLOAT, android inbuilt sensors > were receiving values as float upto 8 decimal places, but I wanted to store > value only upto 6 decimal place, so in android this is the way that first > you will have to convert that value into String , as* String sLongitude = > String.format("%.6f", x);* As others have said, you shouldn't confuse the storage format (how a value is stored in the database) with the presentation (how data is displayed on output). Luckily, recently sqlite got a printf() function. Demo: $ sqlite3 test.db SQLite version 3.8.8 2015-01-30 20:59:27 Enter ".help" for usage hints. sqlite> create table t3 (id INTEGER PRIMARY KEY, lat REAL, lon REAL); sqlite> insert into t3 (id,lat,lon) VALUES (1,1.234567890123,5.6789012345678); sqlite> select printf('id:%3d, latitude: %9.6f, longitude: %9.6f',id,lat,lon) from t3; id: 1, latitude: 1.234568, longitude: 5.678901 sqlite> Hope this helps. -- Regards, Kees Nuyt _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users