From 9b01b90b9e0d0c2f084aff748ff8b88dd9a85c30 Mon Sep 17 00:00:00 2001 From: Rahul Pandey Date: Tue, 7 Mar 2017 17:38:39 +0530 Subject: [PATCH] Update README.md --- README.md | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 4f5e4c8..4c7ca20 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ cordova-plugin-dbcopy Add a prepopulated SQLite database in your Phonegap/Cordova Android and iOS app. -###Note +### Note The database file may have extensions or not for e.g the db file name would be sample.db or sample.sqlite or sample. It doesn't matter what is the file extension, just remember to use the whole filename with extensions(if having one otherwise not) as a paramter when passing to the plugin methods. -###Database file location +### Database file location The database initial location for both platforms has been now changed to www folder. Now you have to put your database file inside www folder. -###Installation +### Installation Plugin can be install with simple cordova plugin add command - @@ -24,93 +24,93 @@ Now you will get a proper plugin response in case of any errors or success. Response format -```` +```javascript { message : "message contains the response string like Invalid DB Location or DB Doesn't Exists or Db Copied Successfully", code: integer value such as 404, 200, 516 } -```` +``` Code - - - **404** - DB or Source or Destination Doesn't exists, see message string. - **516** - DB Already Exists. - **200** - Called Method Executed Successfully. -###Methods +```javascript +404 - DB or Source or Destination Doesn't exists, see message string. +516 - DB Already Exists. +200 - Called Method Executed Successfully. +``` + +### Methods Currently there are two methods supported by the plugin. -* ####Copy +* #### Copy This Method allows you the copy the database from www directory. - - ```` +```javascript window.plugins.sqlDB.copy(dbname, location, success,error); - ```` +``` Here - - **dbname** -> Is the name of the database you want to copy. The dbname can be filename (without extensions) or filename.db or filename.sqlite. The plugin will look for and copy the file according to the filename provided here. And the same file name should be used while opening the database via [SQLitePlugin](https://github.com/litehelpers/Cordova-sqlite-storage). + **dbname** -> Is the name of the database you want to copy. The dbname can be filename (without extensions) or filename.db or filename.sqlite. The plugin will look for and copy the file according to the filename provided here. And the same file name should be used while opening the database via [SQLitePlugin](https://github.com/litehelpers/Cordova-sqlite-storage). - **location** -> You can pass three integer arguments here (Use 0 for Android)- + **location** -> You can pass three integer arguments here (Use 0 for Android)- - ```` + ```javascript (for ios only) location = 0; // It will copy the database in the default SQLite Database directory. This is the default location for database or location = 1; // If set will copy the database to Library folder instead of Documents folder. or location = 2; // (Disable iCloud Backup) If set will copy the database to Library/LocalDatabase. The database will not be synced by the iCloud Backup. - ```` + ``` - **success** -> function will be called if the db is copied sucessfully. + **success** -> function will be called if the db is copied sucessfully. - **error** -> function will be called if the there is some problem in copying the db or the file already exists on the location. + **error** -> function will be called if the there is some problem in copying the db or the file already exists on the location. -* ####Copy Database from Device Storage +* #### Copy Database from Device Storage This is an untested version. Let me know if you have any suggestions. Also Pull Request are always welcome. - ```` +```javascript window.plugins.sqlDB.copyDbFromStorage(dbname, location, source, success, error); - ```` + ``` Here - **dbname** -> Is the name of the database you want to copy. The dbname can be filename (without extensions) or filename.db or filename.sqlite. The plugin will look for and copy the file according to the filename provided here. And the same file name should be used while opening the database via [SQLitePlugin](https://github.com/litehelpers/Cordova-sqlite-storage). **location** -> You can pass three integer arguments here (Use 0 for Android)- - ```` + ```javascript (for ios only) location = 0; // It will copy the database in the default SQLite Database directory. This is the default location for database or location = 1; // If set will copy the database to Library folder instead of Documents folder. or location = 2; // (Disable iCloud Backup) If set will copy the database to Library/LocalDatabase. The database will not be synced by the iCloud Backup. - ```` - + ``` **source** -> Source File location like /sdcard/mydb/db.db. Please provide a valid existing location and the dbname should be present in the path. **success** -> function will be called if the db is copied sucessfully. **error** -> function will be called if the there is some problem in copying the db or the file already exists on the location. - -* ####Copy Database To Device Storage + +* #### Copy Database To Device Storage This is an untested version. Let me know if you have any suggestions. Also Pull Request are always welcome. - ```` +```javascript window.plugins.sqlDB.copyDbToStorage(dbname, location, destination, success, error); - ```` +``` Here - **dbname** -> Is the name of the database you want to copy. The dbname can be filename (without extensions) or filename.db or filename.sqlite. The plugin will look for and copy the file according to the filename provided here. And the same file name should be used while opening the database via [SQLitePlugin](https://github.com/litehelpers/Cordova-sqlite-storage). **location** -> You can pass three integer arguments here (Use 0 for Android)- - ```` + ```javascript (for ios only) location = 0; // It will copy the database in the default SQLite Database directory. This is the default location for database or location = 1; // If set will copy the database to Library folder instead of Documents folder. or location = 2; // (Disable iCloud Backup) If set will copy the database to Library/LocalDatabase. The database will not be synced by the iCloud Backup. - ```` + ``` **destination** -> Destination File location like /sdcard/mydb/db.db. Please provide a valid existing location and the dbname should be present in the path. **success** -> function will be called if the db is copied sucessfully. @@ -121,9 +121,9 @@ This is an untested version. Let me know if you have any suggestions. Also Pull * ####Remove This method allows you to remove the database from the apps default database storage location. - ```` + ```javascript window.plugins.sqlDB.remove(dbname, location, success,error); - ```` + ``` Here - **dbname** -> Is the name of the database you want to remove. If the database file is having any extension, please provide that also. @@ -138,7 +138,7 @@ This method allows you to remove the database from the apps default database sto In your JavaScript or HTML use the following method - -```` +```javascript function dbcopy() { //Database filename to be copied is demo.db @@ -176,4 +176,4 @@ function copyerror(e) console.log("Error Code = "+JSON.stringify(e)); //e.code = 516 => if db exists } -```` +```