mirror of
https://gitee.com/shuto/cordova-plugin-dbcopy.git
synced 2026-04-13 00:00:13 +08:00
Update sqlDB.java
Fixed not initialized destFolder Added check for destFolder existence and error message if doesn't exist
This commit is contained in:
+10
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user