Skip to content

Phonegap-SQLitePlugin for Android #20

Open

Description

@ns-1m

If you reading this, you must be interested on the Android port for this plugin :-).

I think this plugin can be easily ported with your Java knowledge.

Android guys even manage to port Spatialite (GIS extension for SQLite3) library for Android.

PhoneGap SQLiteplugin is right now for iOS devices only (i.e. Objective-C + Javascript).

Hopefully, some can translate the Objective-C to Java (Android SDK) and use the existing Javascipt (PGSQLitePlugin.js from iOS).

However, there are some JSQLite code already. For instance, this project has the necessary files Java Android SDK for SQLite3/Spatialite.

https://github.com/mrenouf/android-spatialite

Somebody would like to knit pick those functions and assembly a Android PhoneGap SQLite plugin.

https://github.com/mrenouf/android-spatialite/tree/master/src/jsqlite

For sure this one of the files.
https://github.com/mrenouf/android-spatialite/blob/master/src/jsqlite/Database.java

Noli

Activity

  1. brody2consult commented on Mar 23, 2012

    @brody2consult
    Contributor

    I would be interested in this kind of port, however I do not have time right now to work on this. Maybe I can work on this sometime in the future. I hope someone will work to make this future-proof by fixing #14 to get this working on Cordova.

  2. macdonst commented on Mar 23, 2012

    @macdonst

    Why not use the Plugin that is already provided in the Android repo? It only gets enabled for certain versions of Android that don't properly support window.openDatabase() but all of the necessary code is already there:

    https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/Storage.java

  3. brody2consult commented on Mar 24, 2012

    @brody2consult
    Contributor

    I am guessing the Android Storage class should emulate the HTML5 Web API in the object returned by window.openDatabase(). I hope we can come up with a solution for #11 to emulate the HTML5 Web API in this plugin for the iOS.

  4. jawwadfarooq commented on Mar 27, 2012

    @jawwadfarooq

    Quite useful if this plugin is available for Android as well

  5. brody2consult commented on Mar 27, 2012

    @brody2consult
    Contributor

    @jawwadfarooq I think it was a very good suggestion by @macdonst to simply use the Plugin that is already provided in the Android repository: https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/Storage.java

    I think it is better if we can adapt a version of this plugin to follow the same Storage API as has already been made for the Android. Someone has already adapted this plugin for Cordova, and I am about to ask if he can make an adaptation to follow the Android Storage API.

  6. brody2consult commented on Apr 4, 2012

    @brody2consult
    Contributor

    https://github.com/chbrody/Cordova-SQLitePlugin/tree/master/DroidGap copied from [sS]torage.j*, use it at your own risk!

  7. ns-1m commented on Apr 4, 2012

    @ns-1m
    Author

    Chris, Brilliant!

    Would it be possible to have this index.html for PGSQLplugin iOS as well.

    https://github.com/chbrody/Cordova-SQLitePlugin/blob/master/DroidGap/assets/www/index.html

    Probably, just rename old index.html to index_lawnchair.html and use
    your index.html as default.

    Thanks.

    Noli

    On 4/5/12, Chris Brody
    reply@reply.github.com
    wrote:

    https://github.com/chbrody/Cordova-SQLitePlugin/tree/master/DroidGap copied
    from [sS]torage.j*, use it at your own risk!


    Reply to this email directly or view it on GitHub:
    #20 (comment)

  8. brody2consult commented on Apr 5, 2012

    @brody2consult
    Contributor

    Well the index.html is just copy-pasting an adapted version of the README sample into the template but yes, I can add something like demo-index.html when I get a chance.

  9. brody2consult commented on Apr 9, 2012

    @brody2consult
    Contributor

    I made some more changes in https://github.com/chbrody/Cordova-SQLitePlugin/ for the Android (DroidGap) version including an API improvement and a common Lawnchair adapter. I still want to do a bit of cleanup before submitting a pull request.

  10. gems09 commented on May 4, 2012

    @gems09

    I use this plugin when it starts inserting in to the db UI got stuck. Please provide the solution for it.

  11. brody2consult commented on May 4, 2012

    @brody2consult
    Contributor

    Can you please specify which version you are using and can you post a sample, as simple as possible, that can demonstrate this behavior?

  12. gems09 commented on May 4, 2012

    @gems09

    Thanks for your response Chris Brody. I am using phonegap 1.2.0 and plugin is for ios. I tried to run the db process in background but it crashes the app. While inserting UI got stuck.

  13. brody2consult commented on May 4, 2012

    @brody2consult
    Contributor

    It is already in the README if you try to save too much data the UI will be blocked. The two solutions I can think of are to use a worker thread or make a timer mechanism. Both are possible from the application layer.

  14. gems09 commented on May 4, 2012

    @gems09

    and this is the sample code for insertion same way i am fetching also.

    database.transaction(function(transaction){

        transaction.executeSql(["INSERT INTO TableName(articleId,  priority, sectionId) VALUES(?,?,?)",temp_ArticleId, temp_Priority, temp_SectionId],function(galTemp_Results){});
    
    });
    
  15. gems09 commented on May 4, 2012

    @gems09

    I tried to run the db operation in background thread i replace the code [self respond:callback withString:[resultSet JSONRepresentation] withType:@"success"]; with [self performSelectorOnMainThread:@selector(saveComplite:)
    withObject:set waitUntilDone:YES]; but app crashes. I don't know what to do. Please give me solution for it. how to write the code for worker thread? Please paste some code.

  16. brody2consult commented on May 4, 2012

    @brody2consult
    Contributor

    @gyanendra-sncet sorry I have never worked with background threads on iOS before so I really cannot help you there. A background thread will only help you if you are doing really large batches, which I believe is not the case for you.

  17. brody2consult commented on May 4, 2012

    @brody2consult
    Contributor

    Also this plugin is no longer supported for PG 1.2.0. Please upgrade to 1.5+, preferably 1.7.0 and try again. You can also checkout my fork, which has support for Android and is closer to the HTML5 SQL API.

  18. gems09 commented on May 4, 2012

    @gems09

    @chbrody Its ok. I have huge data to save in the sqlite so that is why UI is getting blocked so i though if it runs on background thread then ui will not blocked.

  19. gems09 commented on May 4, 2012

    @gems09

    for PG 1.7.0 the sqlite plugin runs on the main thread so t don't think upgrading will solve my problem.

  20. brody2consult commented on May 4, 2012

    @brody2consult
    Contributor

    For a huge data record you would have to add the thread to solve the UI blocking and I think this would have to be done in the plugin. I will raise this in an issue in my fork, cannot promise when or even if I will ever make the solution. Also, would it help you to pre-populate the database like (http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html)?

  21. gems09 commented on May 4, 2012

    @gems09

    Thanks Chris Brody. I have serious problem i need to to fix it. Thanks once again...

  22. gems09 commented on May 4, 2012

    @gems09

    Pre population of db will not work because i am getting the data from server....

  23. gems09 commented on May 18, 2012

    @gems09

    Hi Chris Brody. Any update one adding the thread to solve the UI blocking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions