storesafe / cordova-sqlite-evcore-extbuild-free

Cordova sqlite plugin with Android performance enhancements for PhoneGap Build, GPL v3 or commercial license options
Other
24 stars 13 forks source link

Load password protected sqlite from external storage #8

Open firomero opened 8 years ago

firomero commented 8 years ago

I want to know how to load an external database with password protected. Currently I can load an external database without password protected, but trying to load a protected one:

a statement error callback did not return false: an unknown error was returned: code :0, sqliteCode:1, message: -

Here is my code

  function OpenCustom(path, filename, key) {
        var db = window.sqlitePlugin.openDatabase({name: filename, key:key ,androidDatabaseLocation: path},function () {

            navigator.notification.alert('Database is queried');
            db.transaction(
                function (tx) {
                    tx.executeSql("insert into customerAccounts (firstname, lastname, acctNo) values ('firo"+Math.random()+"','fr"+Math.random()+"','"+Math.random()+"');",[],function(){console.log('ok')},function(statement,error){alert(JSON.stringify(error));});
                    tx.executeSql("SELECT * FROM customerAccounts;",[],function (tx, resultSet) {
                        for (var i=0; i<resultSet.rows.length; ++i){
                            $scope.clients.push(JSON.stringify(resultSet.rows.item(i)));
                        }
                        alert(JSON.stringify(resultSet.rows.length));

                    },function (tx,error) {
                        navigator.notification.alert('select error database'+JSON.stringify(error));
                    });
                },function (error)
                {
                    navigator.notification.alert('Populate database error: ' + error.message);

                }

            );

        }, function (error) {
            navigator.notification.alert('Open database ERROR: ' + JSON.stringify(error));
        });

    }

Using Cordova 6.3.1 deploying in Android 4.4.2.

Best regards

brodycj commented 8 years ago

This version will never support encrypted databases. Encrypted databases are supported by Cordova-sqlcipher-adapter. Combining SQLCipher encryption with user-specified Android database path is under future consideration.

zhangzsan commented 5 years ago

I have the same problem, is there any plugin to solve this problem?