How to take picture using cordova camera and save into sqlite


#1

I got camera and captured an image but i need to save it to my SQLite but i cant add sqlite queries.
At that time errors

$scope.takePicture = function() {
var options = {
quality : 75,
destinationType : Camera.DestinationType.DATA_URL,
sourceType : Camera.PictureSourceType.CAMERA,
allowEdit : false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300,
targetHeight: 300,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};

    $cordovaCamera.getPicture(options).then(function(imageData) {
        $scope.imgURI = "data:image/jpeg;base64," + imageData;
    }, function(err) {
        // An error occured. Show a message to the user
    });
}

where i should do the trick SQLite??

Please Help me
Thanks In advance


#2

Did you find a solution , i’m trying to save the file url path for the image


#4

What solution ! , there’s no solution in the post , if you have one can you share the code sample , please :slight_smile:


#5

use sqlight plugin to store data into db

$cordovaCamera.getPicture(options).then(function(imageData) {

    db = window.sqlitePlugin.openDatabase({name: 'myImages.db', location: 'default'});
    db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS mytab(name, score)');
tx.executeSql('INSERT INTO Mytable VALUES (?,?)', ['Alice',imageData ]);
   });
    $scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function(err) {
    // An error occured. Show a message to the user

});

#6

sir if u get the path so please send me the solution
thanks