Android Question fraction of dbutils limited?

Discussion in 'Android Questions' started by MbedAndroid, Sep 16, 2015.

  1. MbedAndroid

    MbedAndroid Active Member Licensed User

    using DBUtils.DB_REAL i found that the fractionpart is very limited.
    for test i putted in 123.45678901, got back 123.457, checked it with SQlite viewer, got the same when i read it back from the database

    Is there a way to extent the digits to at least 7?
    i'm saving GPS positions into the dabase and 3 digits are really too low for use

    Saving the position as text give me the full fraction of 7 digits

    created the table as following
    Dim m As Map
    m.Initialize
    m.Put("Id", DBUtils.DB_INTEGER)
    m.Put("SpotName", DBUtils.DB_TEXT)
    m.Put("Date", DBUtils.DB_INTEGER)
    m.Put("Time", DBUtils.DB_INTEGER)
    m.Put("Latitude", DBUtils.DB_REAL)
    m.Put("Longitude", DBUtils.DB_REAL)

    DBUtils.CreateTable(SQL1, "spots", m, "Id")
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    DBUtils.DB_REAL is just the name of the field type.

    Can you post the code that you use to insert data and read data?
     
  3. MbedAndroid

    MbedAndroid Active Member Licensed User

    [​IMG]
    Code:
    Dim ListOfMaps As List
                        ListOfMaps.Initialize
                        
    Dim m As Map
                        m.Initialize
                        m.Put(
    "Id", SearchNewId)
                        m.Put(
    "SpotName", ResourceStrings.Get("NEWSPOT"))
                        m.Put(
    "Date",DateTime.Date(DateTime.Now))
                        m.Put(
    "Time"DateTime.Time(DateTime.Now) )
                        m.Put(
    "Latitude",NumberFormat(Point.Latitude,1,7))
                        m.Put(
    "Longitude",NumberFormat(Point.Longitude,1,7))
                        m.Put(
    "test",123.456789012)
                        ListOfMaps.Add(m)
                        DBUtils.InsertMaps(files.SQL1, 
    "spots", ListOfMaps)
    result in sqlite viewer:
    the "test" field was DBUtils.REAL type

    [​IMG] [/url] hebergeur image[/IMG] [/url][/IMG]
     
    Last edited: Sep 16, 2015
  4. klaus

    klaus Expert Licensed User

    Maybe it's related to THIS.
     
  5. MbedAndroid

    MbedAndroid Active Member Licensed User

    didnt noticed that discussion , but you might be right
    anyway as textstring it works fine, testing outerlimits as -179.9999999 and 89.0000001 are well presented using DBUtils.Text
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Don't use NumberFormat here. You are losing the precision. Instead use NumberFormat when you retrieve the data.
     
  7. MbedAndroid

    MbedAndroid Active Member Licensed User

    good advise...modified
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice