Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Chun-Sheng, Li
    @peter279k
    blob
    Christopher J. Brody
    @brodybits
    See litehelpers/Cordova-sqlite-storage#306
    Chun-Sheng, Li
    @peter279k
    OK, I got it.Thanks.
    It worked finally.
    Christopher J. Brody
    @brodybits
    Thanks, happy to hear!
    Rakesh Vidya Chandra
    @krvc

    Hello, I am a newbie who is trying to upgrade an old Cordova IOS app. I need a suggestion on whether Cordova-sqlite-storage plugin is the fix for my issue. Issue: I do need to access the database which is already existing. The old code consists of a function which tries to get the database and it looks like :

        NSArray *libraryPaths = NSSearchPathForDirectoriesInDomains
        (NSLibraryDirectory, NSUserDomainMask, YES);
        NSString *libraryDir = [libraryPaths objectAtIndex:0];
       masterPath = [libraryDir stringByAppendingPathComponent:@"Caches/"];
       databasePath = [libraryDirstringByAppendingPathComponent:@"Caches/file__0/"];      masterFile = [masterPath stringByAppendingPathComponent:masterName];
        databaseFile = [databasePath
                        stringByAppendingPathComponent:databaseName];
        // Execute the "checkAndCreateDatabase" function
        [self checkAndCreateDatabase];
    
        NSUserDefaults* appPreferences = [NSUserDefaults standardUserDefaults];
        NSBundle* mainBundle = [NSBundle mainBundle];
    ...........
    .........

    I am facing the an error: sqlite prepare statement error - no such table
    when I run the app. Should I use the Cordova-sqlite-storage plugin instead of using this code. Please correct me if I am missing anything.

    Thanks in advance.
    Christopher J. Brody
    @brodybits
    The old code seems to put the database in a Caches/file__0 subdirectory but the sqlite plugin does not look there. I can think of a couple of options to solve this:
    You should be able to use the Cordova File plugin to copy the database to Documents if it does not already exist there. This is very similar to how the pre-populated database functionality works.
    Christopher J. Brody
    @brodybits
    The second option is to use the pre-populated database functionality but modify SQLitePlugin.m to copy the database from Caches/file__0 instead of www.
    Rakesh Vidya Chandra
    @krvc
    Thanks a lot for your suggestions Chris :smile: I will try out your suggestions.
    Carson Huang
    @kot09
    Hey brodybits. If I use a query like this "CREATE TABLE IF NOT EXISTS ...", what would be be the callback's parameters? I want something to happen only on the creation
    Christopher J. Brody
    @brodybits
    You can add a success callback function in your tx.executeSql('CREATE TABLE IF NOT EXIST...'... statement. If the CREATE TABLE statement is executed successfully your success callback function is called if provided with the tx and results parameters. The results parameter will not have any useful information for CREATE or DROP queries.
    Rakesh Vidya Chandra
    @krvc
    Hello Chris, I am using Sqlite storage plugin while upgrading my IOS Cordova project. When I run the application I am facing an issue with the error: Deprecated attempt to access property 'userAgent' on a non-Navigator object. And my remote debugger is taking me to the SqlitePlugin.js file in the stacktrace of error. What would be the culprit. This is my stack trace: http://imgur.com/B38P38p
    Rakesh Vidya Chandra
    @krvc
    Thank you Chris for your prompt response. I tried that solution, but it didn't work. If you have a look on to the stacktrace you can see the cordova file that is being accessed is cordova-3.1.0.js. But I have updated my IOS platform to Cordova-3.8.0. Could it be the reason for the issue?
    Christopher J. Brody
    @brodybits
    It is possible. Please make sure you are running with the right version of the Cordova Javascript.
    Rakesh Vidya Chandra
    @krvc
    Thank you Chris
    rickarddahlinfor
    @rickarddahlinfor
    Hi! I’m trying to use the auto-vaccum pragma, but can’t get it to work. I’m doing the "PRAGMA auto_vaccum = 1;” directly after running the openDatabase function (the database file do not exist before the openDatabase call). I then add about 100 mb of data, then deleting it. I expected the db file to reduce itself after the delete, but it remains at 100 mb. As far as I understand it, this should work… I’m using ”io.litehelpers.cordova.sqlite 0.7.7” on cordova 5.1.1.
    Christopher J. Brody
    @brodybits
    Hi sorry I did not see your message earlier. Please specify which platform and open database options. I have read about some problems with auto_vacuum in the past
    Best if you can raise this as an issue
    rickarddahlinfor
    @rickarddahlinfor

    Hi again! I have now made some more testing, and I got ”PRAGMA AUTO_VACUUM = 1;” to work by executing ”VACUUM;” directly after the auto_vacuum statement is executed. This is (?) a bug and I will file an issue on it.

    I using an iOS 8.4 simulator. The open parameters are "window.sqlitePlugin.openDatabase({name: db_name, location: 2, createFromLocation: 1});”.

    Christopher J. Brody
    @brodybits
    Thanks for letting me know. This may be because of how sqlite3.c is built. I will document this in the readme when I get a chance.
    greatredpie
    @greatredpie
    Hi. Sorry bit of a phone gap noob. When building this app with build.phonegap.com can I just add this plugin to the config.xml file, rather than installing the plugin using the CLI. As shown here: http://docs.build.phonegap.com/en_US/configuring_plugins.md.html#Plugins
    Christopher J. Brody
    @brodybits
    Yes that should work. If not you can file an issue.
    lyric123123
    @lyric123123
    blob
    This is my file source tree.
    08-27 11:31:20.065: W/dalvikvm(5138): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lio/liteglue/SQLitePlugin;
    08-27 11:31:20.185: W/System.err(5138): java.lang.ClassNotFoundException: io.liteglue.SQLitePlugin
    08-27 11:31:20.185: W/System.err(5138): at java.lang.Class.classForName(Native Method)
    08-27 11:31:20.195: W/System.err(5138): at java.lang.Class.forName(Class.java:251)
    08-27 11:31:20.195: W/System.err(5138): at java.lang.Class.forName(Class.java:216)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:403)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:193)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.PluginManager.exec(PluginManager.java:141)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
    08-27 11:31:20.295: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
    08-27 11:31:20.295: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
    08-27 11:31:20.305: W/System.err(5138): at android.os.Handler.dispatchMessage(Handler.java:102)
    08-27 11:31:20.305: W/System.err(5138): at android.os.Looper.loop(Looper.java:136)
    08-27 11:31:20.305: W/System.err(5138): at android.os.HandlerThread.run(HandlerThread.java:61)
    08-27 11:31:20.315: W/System.err(5138): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sqlc-native-driver from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.ionicframework.testplugin2382207-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.testplugin2382207-1, /system/lib]]]: findLibrary returned null
    08-27 11:31:20.315: W/System.err(5138): at java.lang.Runtime.loadLibrary(Runtime.java:358)
    08-27 11:31:20.315: W/System.err(5138): at java.lang.System.loadLibrary(System.java:526)
    08-27 11:31:20.375: W/System.err(5138): at io.liteglue.SQLiteConnector.<init>(SQLiteConnector.java:8)
    08-27 11:31:20.375: W/System.err(5138): at io.liteglue.SQLitePlugin.<clinit>(SQLitePlugin.java:47)
    08-27 11:31:20.385: W/System.err(5138): ... 13 more
    08-27 11:31:20.385: I/System.out(5138): Error adding plugin io.liteglue.SQLitePlugin.
    08-27 11:31:20.385: W/System.err(5138): java.lang.NullPointerException
    08-27 11:31:20.415: W/System.err(5138): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:195)
    08-27 11:31:20.425: W/System.err(5138): at org.apache.cordova.PluginManager.exec(PluginManager.java:141)
    08-27 11:31:20.435: W/System.err(5138): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
    08-27 11:31:20.435: W/System.err(5138): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
    08-27 11:31:20.435: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
    08-27 11:31:20.435: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
    08-27 11:31:20.435: W/System.err(5138): at android.os.Handler.dispatchMessage(Handler.java:102)
    08-27 11:31:20.445: W/System.err(5138): at android.os.Looper.loop(Looper.java:136)
    08-27 11:31:20.445: W/System.err(5138): at android.os.HandlerThread.run(HandlerThread.java:61)
    08-27 11:31:21.615: I/Choreographer(5138): Skipped 54 frames! The application may be doing too much work on its main thread.
    08-27 11:31:22.405: I/Choreographer(5138): Skipped 47 frames! The application may be doing too much work on its main thread.
    Christopher J. Brody
    @brodybits
    SQLitePlugin.java should have been installed in src/io/liteglue
    lyric123123
    @lyric123123
    Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sqlc-native-driver from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.ionicframework.testplugin2382207-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.testplugin2382207-1, /system/lib]]]: findLibrary returned null But, I have added the sqlite - native - driver. Jar file
    Christopher J. Brody
    @brodybits
    You may have to extract the contents of the lib subdirectory of sqlite-native-driver.jar into your libs directory, and remove sqlite-native-driver.jar from your project
    lyric123123
    @lyric123123
    blob
    How to extract the sqlite - native - driver lib subdirectory of the content.
    Christopher J. Brody
    @brodybits
    jar xf sqlite-native-driver.jar
    then do something like mv lib/* libs
    lyric123123
    @lyric123123
    Why can't directly use sqlite - native - driver. jar? I am a beginner, don't know the inside of the principle.
    Christopher J. Brody
    @brodybits
    It should be possible but certain Android implementations do not expect it
    Let me correct it. This is normal for regular Java, but Android is not regular Java. Android takes regular Java class files and converts them to DEX format before making the APK.
    lyric123123
    @lyric123123
    Excuse me, where is your ever using Cordova sqlite-storage small demo of success ,android.
    Christopher J. Brody
    @brodybits
    Hundreds, maybe thousands of apps already using it!
    lyric123123
    @lyric123123
    I know
    Christopher J. Brody
    @brodybits
    How do you create the app? Are you using the cordova cli or something else?
    If you are having trouble, it is best to start with an extremely simple test, such as what I put in README.md.
    lyric123123
    @lyric123123
    Ionic + cordova ,but this is an extremely simple test.
    Christopher J. Brody
    @brodybits
    Aah yes. Ionic, which I think you know is basically a version of Angular with the UI framework, can be a pain to use with Cordova. They have ngCordova.
    lyric123123
    @lyric123123
    Thanks
    lyric123123
    @lyric123123
    At the same mistake again.

    I downloaded the zip file from that site (the link is at the top right), then extracted the two files in the folder (src/android/libs) and placed them in the project's libs directory. Then, I refreshed the project.

    As the error kept going, he told me to "Make sure you removed sqlite-native-driver.jar". I deleted that file from the libs directory, refreshed the project, and The following error.

    08-27 11:31:20.065: W/dalvikvm(5138): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lio/liteglue/SQLitePlugin;
    08-27 11:31:20.185: W/System.err(5138): java.lang.ClassNotFoundException: io.liteglue.SQLitePlugin
    08-27 11:31:20.185: W/System.err(5138): at java.lang.Class.classForName(Native Method)
    08-27 11:31:20.195: W/System.err(5138): at java.lang.Class.forName(Class.java:251)
    08-27 11:31:20.195: W/System.err(5138): at java.lang.Class.forName(Class.java:216)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:403)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:193)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.PluginManager.exec(PluginManager.java:141)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
    08-27 11:31:20.195: W/System.err(5138): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
    08-27 11:31:20.295: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
    08-27 11:31:20.295: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
    08-27 11:31:20.305: W/System.err(5138): at android.os.Handler.dispatchMessage(Handler.java:102)
    08-27 11:31:20.305: W/System.err(5138): at android.os.Looper.loop(Looper.java:136)
    08-27 11:31:20.305: W/System.err(5138): at android.os.HandlerThread.run(HandlerThread.java:61)
    08-27 11:31:20.315: W/System.err(5138): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sqlc-native-driver from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.ionicframework.testplugin2382207-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.testplugin2382207-1, /system/lib]]]: findLibrary returned null
    08-27 11:31:20.315: W/System.err(5138): at java.lang.Runtime.loadLibrary(Runtime.java:358)
    08-27 11:31:20.315: W/System.err(5138): at java.lang.System.loadLibrary(System.java:526)
    08-27 11:31:20.375: W/System.err(5138): at io.liteglue.SQLiteConnector.<init>(SQLiteConnector.java:8)
    08-27 11:31:20.375: W/System.err(5138): at io.liteglue.SQLitePlugin.<clinit>(SQLitePlugin.java:47)
    08-27 11:31:20.385: W/System.err(5138): ... 13 more
    08-27 11:31:20.385: I/System.out(5138): Error adding plugin io.liteglue.SQLitePlugin.
    08-27 11:31:20.385: W/System.err(5138): java.lang.NullPointerException
    08-27 11:31:20.415: W/System.err(5138): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:195)
    08-27 11:31:20.425: W/System.err(5138): at org.apache.cordova.PluginManager.exec(PluginManager.java:141)
    08-27 11:31:20.435: W/System.err(5138): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
    08-27 11:31:20.435: W/System.err(5138): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
    08-27 11:31:20.435: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
    08-27 11:31:20.435: W/System.err(5138): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
    08-27 11:31:20.435: W/System.err(5138): at android.os.Handler.dispatchMessage(Handler.java:102)
    08-27 11:31:20.445: W/System.err(5138): at android.os.Looper.loop(Looper.java:136)
    08-27 11:31:20.445: W/System.err(5138): at android.os.HandlerThread.run(HandlerThread.java:61)
    08-27 11:31:21.615: I/Choreographer(5138): Skipped 54 frames! The application may be doing too much work on its main thread.
    08-27 11:31:22.405: I/Choreographer(5138): Skipped 47 frames! The application may be doing too much work on its main thread.