an-rahulpandey / cordova-plugin-dbcopy

Copy SQLite Database from www folder to default app database location
Apache License 2.0
89 stars 48 forks source link

Can't "import" the methods #35

Closed ghost closed 7 years ago

ghost commented 7 years ago

Thanks a lot for this plugin. I hope you can help me to make it run in my environment.

This is my cordova_plugins.js:


cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
    {
        "file": "plugins/cordova-plugin-dbcopy/www/sqlDB.js",
        "id": "cordova-plugin-dbcopy.sqlDB",
        "pluginId": "cordova-plugin-dbcopy",
        "clobbers": [
            "window.plugins.sqlDB"
        ]
    },
    {
        "file": "plugins/cordova-sqlite-storage/www/SQLitePlugin.js",
        "id": "cordova-sqlite-storage.SQLitePlugin",
        "pluginId": "cordova-sqlite-storage",
        "clobbers": [
            "SQLitePlugin"
        ]
    }
];
module.exports.metadata = 
// TOP OF METADATA
{
    "cordova-plugin-dbcopy": "1.0.4",
    "cordova-plugin-whitelist": "1.3.0",
    "cordova-sqlite-storage": "1.4.8"
}
// BOTTOM OF METADATA
});

I can't copy the db cuz I'm getting TypeError: Cannot read property 'sqlDB' of undefined

I saw this in other issues but I'm using Chrome, that supports websql.

an-rahulpandey commented 7 years ago

Hi The plugin only works with Sqlite db on phone, it will not work on web browser with websql.

ghost commented 7 years ago

Hey Rahul, thanks a lot for you answer, but I'm getting this error even when I run in my device. It's seems that I can't use the methods...

Attached a screen shot of the problem taken with the USB debugging tool for Chrome.

screen shot 2016-11-02 at 10 48 43 am

an-rahulpandey commented 7 years ago

Are you using sqlite database? The plugin is configured for sqlite db only.

ghost commented 7 years ago

Ya, I'm using sqlite. It seems that the problem didn't reach the database yet, I can't even use the methods copy/remove from the plugin, I mean, it seems that I never added the plugin using the CLI, but I did it!

I'm wondering if you can share some code with a working DB to exemplify how it is used. Dunno if I'm asking a lot, I never made a mobile app before.

Thanks anyway for your kindly responses!

an-rahulpandey commented 7 years ago

How are you running the app? using some IDE or CLI?

an-rahulpandey commented 7 years ago

If you are using CLI make sure you have run cordova prepare android && cordova build android command.

an-rahulpandey commented 7 years ago

Also does the config.xml inside platforms directory (platforms/android/res/) have sqlDB entry?

ghost commented 7 years ago

Hey Rahul!

Got it working after following these instructions: https://github.com/ymochi/prepopulated-DB-for-hybrid-applications

It's working perfectly, thx a lot for your time and patience.