Update sqlDB.java

Fixed not initialized destFolder
Added check for destFolder existence and error message if doesn't exist
This commit is contained in:
rafaellop
2017-03-08 09:56:50 +01:00
committed by GitHub
parent a3f362ba03
commit 3eef3a301c
+10 -1
View File
@@ -158,17 +158,26 @@ public class sqlDB extends CordovaPlugin {
private void copyDbToStorage(String dbname, String dest, final CallbackContext callbackContext){
File source = cordova.getActivity().getDatabasePath(dbname);
File destFolder;
File destFolder;
File destination;
if(dest.indexOf("file://") != -1){
destination = new File(dest.replace("file://","") + dbname);
} else {
destination = new File(dest + dbname);
}
destFolder = new File(dest);
if(!destFolder.exists()){
destFolder.mkdirs();
}
if(!destFolder.exists()) {
sendPluginResponse(404, "Invalid output DB Location", true, callbackContext);
return;
}
if(source.exists()) {
this.newCopyDB(source,destination,callbackContext);
} else {