CRUD operation in PhoneGap application using SQLite Database

Few days ago I received a comment from one of the reader of my blog to show an example on CRUD (Create, Read, Update and Delete) with the database. So in this post we will explore the use of CRUD operation using SQLite database in PhoneGap application.

CRUD can be described as a process, which helps the user to add, view, search and modify the information inside the database.

Here are the basic steps which demonstrates CRUD operation.

  • Create or add new entries
  • Read, retrieve, search or view existing entries
  • Update, modify or edit existing entries
  • Delete, deactivate or destroy existing entries

Before doing any operation on database let’s initialize the database first, either using HTML5 local database concept or using SQLite plugin.
Continue reading

Saving user preferences in iOS using Xamarin

Xamarin provides a number of ways to save data in iOS using Local Storage. User preferences are generally stored in Library/Preferences/.
Xamarin iOs provides its built in mechanism i.e. instead of creating files directly in the directory it is suggested to use NSUserDefaults class to save data.

NSUserDefaults class provides its own built in mechanisms to save float, double, integers, Boolean and URL data. To save a custom object it should be converted to NSData object using NSUserDefaults.
Continue reading

Fix the Web View shrink issue in iOS7 using PhoneGap

I received a bug ticket from my client about the unusual behavior of my application UI. It was a problem which was occurring only in iOS7 only.
When the keyboard pops up in iPad devices running on iOS7 the web view of our app gets shrink (app development using Phonegap).

Solution that works for me :
This problem can be solved in few steps.

  1. We need to go to Config.xml and inside the preference tag just need to set the value of KeyboardShrinksView to false.
  2. Continue reading

Adding events to native calendar in PhoneGap iOS application

While developing a PhoneGap application, I got a new requirement to add an event to native calendar from the application. So that user can get aware of the details of the event from native calendar.

To implement the same, I goggled for while and found a nice and interesting plugin which is very easy to integrate and works with PhoneGap smoothly. It allows the user to add the event to calendar of that device. Here are the steps bellow which will guide to integrate the calendar plugin in PhoneGap iOS application.

1. Download the calendar plugin from github by using this URL.
Continue reading

Copy existing sqlite database into PhoneGap iOS application

Usually PhoneGap supports SQLite database to interact locally. There might be a scenario where we need to create the database freshly or sometimes need to use the existing database. The idea of writing this blog came to my mind while encountered a question in stackoverflow site.  In this blog we will focus on importing existing database into our PhoneGap application and use the same to interact with our application.

Lets have a pre-populated database having tables with data which needs to be imported to our application. It will help us to minimize our effort in creating the database freshly to the application on its startup. For this we need to follow the bellow steps.

Step 1 : Remove the .sqlite extension from the sqlite database. Ex. If we have the database called DummyDB.sqlite make it only DummyDB.
Continue reading

Integrate SQLite plugin in PhoneGap iOS application

For offline storage in PhoneGap application, we can use local storage or storage API. But there are some limitations of this storage mechanism. So here we will discuss on creating local database with larger storage limits with the help of SQLite plugin.

To overcome the limitations, we can use the SQLite plugin which is very easy to integrate. Here are the steps below which will guide to integrate the SQLite plugin in PhoneGap iOS application.

1. Download the SQLite plugin from github by using this url.

2. The plugins are inside Cordova-SQLitePlugin / src / ios /. Let’s drag the SQLitePlugin.h and SQLitePlugin.m files into the Plugins directory in Xcode and choose the “Create folder references for any added folders” option while adding reference.
Continue reading

Integrating iAd in a PhoneGap Project

As the name suggests iAd is a mobile advertising platform provided by Apple to embed advertisements into the app. The new feature of iAd makes the content of the app more lively and dynamic, since clicking on an advertisement unlike the previous one it does not navigate away to Safari but opens a new Pop-up Window for the Ad inside the app.

To integrate an Ad using the iAd framework we need to mainly modify the MainViewController.h and MainViewController.m files by adding some additional code to it.

Below is the integration guide as follows.

We need to open project navigator, then click on the Build Phases tab.

Here we will find the row Link Binary With Libraries. We need to add iAd.framework to the project by clicking on the Add(+) button( at lower left end). Continue reading