AngularJS allows to define async functions. An example is the $http service. HTTP service calls an API and returns a response as a promise.

$http.get(url)
    .then(function(res){
        // handle the response
    }, function(res){
        // handle the error
    });

Retrieve the result from the Promise object using then function. The function has two arguments: onSuccess callback and onFailure callback.

The $q service in AngularJS creates a promise using the defer function.…

Read More

Isolated Storage in Windows Phone stores data specific to an app. The storage space is not shared with other apps. SQLite is a light-weight database. And for mobile apps, it is common to store app specific data in SQLite. Windows Phone apps store SQLite database in Isolated Storage.

The usual way to open a connection to the SQLite database is using the path to the database file.…

Read More

SQLite is an open-source SQL database engine. It is widely used in iOS apps. The database is available in the form of a file.

Create Database

To create a database with name accounting:

sqlite3 accounting.sqlite

.tables is a command which lists all tables. Add a new table, Company. And insert a few rows.

CREATE TABLE company 
(id int, seats int);
INSERT INTO company (id, seats)
VALUES (1, 20);
INSERT INTO company (id, seats)
VALUES (2, 30);
INSERT INTO company (id, seats)
VALUES (3, 50);

ALTER TABLE has restricted syntax.…

Read More

SQLite database has native support in iOS. The post provides a simple helper class that you can use to retrieve data and perform update operations on the data.

The helper class uses the libsqlite3.dylib library. Link the XCode project with the library. Create a helper class in Objective-C: DbHelper.

Header file

Define the DbHelper class with a static method (getInstance) to create a singleton instance.…

Read More