SQLitePlugin - Initial Experience

3 posts, 1 answers
  1. Answer
    Michael
    Michael avatar
    21 posts
    Member since:
    Apr 2011

    Posted 19 Mar 2013 Link to this post

    Would it make sense to have a separate 'Plugin' area in the forums? I wasn't sure where to post this.

    I have started using the SQLite plugin and thought i would share my experience with storing dates.

    Before i begin does anyone know if there is a way to stop all the SQLitePlugin console messages appearing? there is a lot of them and it is hard to see all my own messages with the SQLitePlugin messages being displayed as well.

    Dates:
    Initially I tried storing dates in the database as  an integer (ms from 1st Jan 1970) using getTime()
    and then converting the interger back to a js Date Object using new Date(databaseValue)

    This worked OK in Android 2.3 but for some reason in Android 4.03 the values were not being stored correctly,  e.g. the number 1361836800000 became 332167168 when read back from the database. I've no idea why!

    I then moved to storing the dates as TEXT in the format yyyy-MM-dd HH:mm:ss using kendo.toString(date, "yyyy-MM-dd HH:mm:ss") to convert the date to  a string for saving in the db and new Date(strdate) to convert from database string back to a date.
    This works in Android 2.3 & 4.03 but failed in IOS 5 AHHHHHH!!!
    It turns out that some IOS browsers don't accept one of the most common datetime formats!! I finally ended up writing a date function that splits out the date elements from the string before converting then to a javascript Date object, so far so good, i hope this helps others.

      if(!strdate)
            return new Date(0);
        else
        {
            arr = strdate.split(/[- :]/);
            return new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);
        }

    Kendo UI / Icenium Team, how about some more detailed demos using the SQLitePlugin please, the one I found was very basic, it would be good to see proper date manipulation and using it with kendo DataSource & MVVM scenarios.

  2. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 19 Mar 2013 Link to this post

    With regard to console messages, could it be that Icenium has set the 'log level' to 'debug':
    https://github.com/brodyspark/PhoneGap-SQLitePlugin-Android#android-platform

    The issues you are seeing are also maybe related to the plug-in itself and not to Icenium (it is a plugin after all).
  3. Michael
    Michael avatar
    21 posts
    Member since:
    Apr 2011

    Posted 19 Mar 2013 Link to this post

    The log level set to DEBUG could be the problem but how can I remove / change it from within Icenium?

    I would like to make it clear my problems with dates & SQLite are general problems with javascript dates & SQLlite development and not with Icenium, its just such a fundamental problem I thought I would share so it may help others.
Back to Top