Step 1 - Goto the Cordova-SQLitePlugin Github Page and download the project (Cordova-SQLitePlugin-master.zip)
Step 2 - Create your PhoneGap project and open it in Xcode.
Step 3 - Goto the "Build Phases" of you Xcode project -> Click the dropdown "Link Binary with Libraries" and add
Step 4 - Unzip the file "Cordova-SQLitePlugin-master.zip" goto the folder src/ios/ you will find SQLitePlugin.h and SQLitePlugin.m file there.
Step 5 - Drag those files to the plugin folder in your Xcode project. Make sure that you tick the "copy items to destination folder.
Step 6 - Same way you should add the following files to the js folder in Xcode project.
* lawnchair.js
* SQLitePlugin.js
* Lawnchair-sqlitePlugin.js
Step 7 - Include these files in the index.html of your project. Use the code below.
<script type="text/javascript" src="js/Lawnchair-sqlitePlugin.js"></script>
<script type="text/javascript" src="js/lawnchair.js"></script>
<script type="text/javascript" src="js/SQLitePlugin.js"></script>
Step 8 - Add the following code between you <head> </head> tag.
Step 2 - Create your PhoneGap project and open it in Xcode.
Step 3 - Goto the "Build Phases" of you Xcode project -> Click the dropdown "Link Binary with Libraries" and add
libsqlite3.dylib
or libsqlite3.0.dylib
.Step 4 - Unzip the file "Cordova-SQLitePlugin-master.zip" goto the folder src/ios/ you will find SQLitePlugin.h and SQLitePlugin.m file there.
Step 5 - Drag those files to the plugin folder in your Xcode project. Make sure that you tick the "copy items to destination folder.
Step 6 - Same way you should add the following files to the js folder in Xcode project.
* lawnchair.js
* SQLitePlugin.js
* Lawnchair-sqlitePlugin.js
Step 7 - Include these files in the index.html of your project. Use the code below.
<script type="text/javascript" src="js/Lawnchair-sqlitePlugin.js"></script>
<script type="text/javascript" src="js/lawnchair.js"></script>
<script type="text/javascript" src="js/SQLitePlugin.js"></script>
Step 8 - Add the following code between you <head> </head> tag.
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
console.log("Run1");
var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
});
db.transaction(function (tx){
for (var index = 1; index < 10; index++){
tx.executeSql('INSERT INTO LOGS (id,log) VALUES ('+index+', '+index+')');
}
});
}
</script>
Step 9 - Include the following in your config file.
<feature name="SQLitePlugin">
<param name="ios-package" value="SQLitePlugin" />
</feature>
Step 10 - Run your project. Open FInder and goto ->User->Library->Application Support->iPhone Simulator->7.0 -> Applications -"Your Application" -> Documents if you find a file named MYDB.Sqlite then try to open it using some SQLite DB Manager. (I use a Mozilla Firefox plugin named SQLite Manager)
Done !!!
In Documents Folder Database is not created Help me out!!!!!!!
ReplyDeleteCould you please elobarate your trouble in detail ? Any error message in console? Did you tried placing some logs to check the execution ?
DeleteSuccessfully i created a project and ios phonegap using command prompt. then i download Cordova-SQLitePlugin in Github Page... in xcode build phase i add that link library then i copy .h and .m files in plugin folder and similar like other 3 js files in index.html i edit and add ur code in config file i adder ur feature tag also after successful build using window+shift+g i moved my project directory but in documents folder sqlite file not created there
Deleteu have any source code copies for this concept means send that to the below mail id prithivi@meliosystems.com or else the detail explanation how to implement sqlite database in phonegap ios...... and one thing i have sql db manager firefox plugin also
ReplyDeleteHi dude its Worked... I want to know some other interesting experiments in phonegap
ReplyDeleteGood Keep tuned :)
DeleteThis comment has been removed by the author.
ReplyDeleteCan u provide same tutorial for android..??
ReplyDeleteInstalation of Cordova/PhoneGap SQLitePlugin to Android PhoneGap Project.
hello, am using ios 6.1 , but there is no config file to add the sqliteplugin.How can i do that & it stating the error "Plugin 'SQLitePlugin' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist."
ReplyDeletePlease help me
Thanks
ReplyDeleteCominform is your partner for efficient, custom-tailored business software-solutions. The Cominform team develops on innovative platforms and in line with cutting-edge standards. Here are options for Web Desktop,Web-Desktop, SAML Cordova Plugin , SQL Cordova Plugin , SAML Phonegap Plugin and SQL Phonegap Plugin.
ReplyDelete