Downloaded prepopulated SQLite DB

Greetings,

I want to know how can i move the file database.db to the www folder in android and ios, so then i can work with cordova-plugin-dbcopy, or if there is a better way to work with my database.db.

i have this code i tried to copy and move the file to the applicationDataDirectory but nothing happens, I check the debugger with chrome but it never enter, just jump to the next step.

$cordovaFile.moveFile(cordova.file.dataDirectory, “Database.db”, cordova.file.applicationDirectory, “Database.db”)

i need to move the file after i downloaded and unzip.

please any help, thanks, bellow i let my code to you can watch, thanks again.

UPDATED
i already have the database in the cordova.file.dataDirectory i unzip it to this directory, but now i want to read the database.db i don’t know how to tell openDB from that location or if i need to put in some other place to be read.

UPDATED CODE

//#####################################DESCARGO EL ARCHIVO ZIP ####################################
$cordovaFileTransfer.download($rootScope.urlDownload, targetPath, options, trustHosts)
.then(function(result) {
// Success!
alert("Ok la descarga: "+JSON.stringify(result));
//#########################DESCOMPRIMO ARCHIVO ZIP #####################################
$cordovaZip
.unzip(
result.nativeURL,
cordova.file.dataDirectory
).then(function () {
alert(“ok descomprimiendo”);
//######################### VERIFICO ARCHIVO DATABASE ###################################
$scope.directorio = cordova.file.dataDirectory;
alert($scope.directorio);
$cordovaFile.checkFile($scope.directorio, ‘DataBase.db’)
.then(function (success) {
alert(“si existe database”);
$rootScope.DataBase = cordova.file.dataDirectory+‘Database.db’;
//cordova.file.dataDirectory
$rootScope.db = $cordovaSQLite.openDB({ name: “Database.db” });

                  //#################### VERIFICO ARCHIVO TEMP ########################################
                    $cordovaFile.checkFile(cordova.file.dataDirectory, 'Temp.db')
                    .then(function (success) {
                      
                      alert("si existe temporal");
                      $rootScope.Temp = cordova.file.dataDirectory+'Temp.db'; 
                      $scope.progreso = "Proceso Terminado Satisfactoriamente";
                      // success
                    }, function (error) {
                      alert("error verificando Temp.db"+error);
                      // error
                    });
                  //######################END VERIFICO ARCHIVO TEMP ##################################    
                  // success
                }, function (error) {
                  alert("error verificando Database.db"+error);
                  // error
                });
              //##########################END VERIFICO ARCHIVO DATABASE ##############################  
              console.log('success');
            }, function () {
              console.log('error');
            }, function (progressEvent) {
              $scope.unzipProgress = Math.round((progressEvent.loaded / progressEvent.total) * 100);
              $scope.progreso = "Descomprimiendo... "+$scope.unzipProgress+" %"
              console.log(progressEvent);
            });
    //#########################END DESCOMPRIMO ARCHIVO ZIP #####################################

    }, function(error) {
      // Error
      alert(JSON.stringify(error));
    }, function (progress) {
      $timeout(function () {
        $scope.downloadProgress = Math.round((progress.loaded / progress.total) * 100);
        $scope.progreso = "Descargando Información... "+$scope.downloadProgress+" %";
      })
    });

//##################################FIN DESCARGO ARCHIVO ZIP ###########################################

END UPDATED CODE

    //#####################################DESCARGO EL ARCHIVO ZIP ####################################
      $cordovaFileTransfer.download($rootScope.urlDownload, targetPath, options, trustHosts)
        .then(function(result) {
          // Success!
          alert("Ok la descarga: "+JSON.stringify(result));
          //#########################DESCOMPRIMO ARCHIVO ZIP #####################################
          $cordovaZip
                .unzip(
                  result.nativeURL, 
                  cordova.file.dataDirectory 
                ).then(function () {
                  alert("ok descomprimiendo");
                  //######################### VERIFICO ARCHIVO DATABASE ###################################
                    $cordovaFile.checkFile(cordova.file.dataDirectory, 'DataBase.db')
                    .then(function (success) {
                      alert("si existe database");
                      $rootScope.DataBase = cordova.file.dataDirectory+'Database.db';                      
                      $cordovaFile.moveFile(cordova.file.dataDirectory, "Database.db", cordova.file.applicationDirectory, "Database.db")
                            .then(function (success) {
                              alert("movido ok");
                              // success
                            }, function (error) {
                              // error
                            });
                      //#################### VERIFICO ARCHIVO TEMP ########################################
                        $cordovaFile.checkFile(cordova.file.dataDirectory, 'Temp.db')
                        .then(function (success) {
                          
                          alert("si existe temporal");
                          $rootScope.Temp = cordova.file.dataDirectory+'Temp.db'; 
                          $scope.progreso = "Proceso Terminado Satisfactoriamente";
                          // success
                        }, function (error) {
                          alert("error verificando Temp.db"+error);
                          // error
                        });
                      //######################END VERIFICO ARCHIVO TEMP ##################################    
                      // success
                    }, function (error) {
                      alert("error verificando Database.db"+error);
                      // error
                    });
                  //##########################END VERIFICO ARCHIVO DATABASE ##############################  
                  console.log('success');
                }, function () {
                  console.log('error');
                }, function (progressEvent) {
                  $scope.unzipProgress = Math.round((progressEvent.loaded / progressEvent.total) * 100);
                  $scope.progreso = "Descomprimiendo... "+$scope.unzipProgress+" %"
                  console.log(progressEvent);
                });
        //#########################END DESCOMPRIMO ARCHIVO ZIP #####################################

        }, function(error) {
          // Error
          alert(JSON.stringify(error));
        }, function (progress) {
          $timeout(function () {
            $scope.downloadProgress = Math.round((progress.loaded / progress.total) * 100);
            $scope.progreso = "Descargando Información... "+$scope.downloadProgress+" %";
          })
        });
  //##################################FIN DESCARGO ARCHIVO ZIP ###########################################

This should cover your problem: https://blog.nraboy.com/2015/01/deploy-ionic-framework-app-pre-filled-sqlite-db/

Gajotres thanks for your answer, but i understand that i need to save the database in the www folder, but i don’t know how to do this, because the database.db is downloaded from the app when the user press a button, if you can tell me how to move the database.db to the folder www I will very thankful.