Hot File

SQLite for Windows Phone 8

View: 1977    Dowload: 0   Comment: 0   Post by: hanhga  
Author: Ranjan.D   Category: Windows phone   Fields: Computers - Technology

8 point/7 review File has been tested

In this tutorial we will see with an example how to use SQLite in Windows Phone 8. Note: this tip is just an introduction about the usage of the SQLite library in Windows Phone 8.

Introduction

Setting up SQLite in a Windows Phone 8 Solution:

  1. Download SQLiteWinRTPhone project from http://sqlwinrt.codeplex.com/SourceControl/latest and compile it.
  2. You must download and install SQLite for Windows Phone Visual Studio Extension http://visualstudiogallery.msdn.microsoft.com/cd120b42-30f4-446e-8287-45387a4f40b7. It's a light weight self contained, zero configuration database engine.
  3. Create a Windows Phone 8 Project and reference SQLite for Windows Phone Extension as below and add a reference to “SQLiteWinRTPhone”.

Background

A little knowledge about the usage of SQLite.

Using the code

Below is the code block for the SQLite database and table creation.

private async void CreateDatabaseButtonClicked(object sender, RoutedEventArgs e)
{
  Database database = new Database(ApplicationData.Current.LocalFolder, "usertask.db");

  await database.OpenAsync();

  string query = "create table if not exists Tasks " +
                       "(Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," +
                       "Task varchar(100)" 
                       )";

  await database.ExecuteStatementAsync(query);
}

Below is the code block to add tasks.

private async void AddTasksButtonClicked(object sender, RoutedEventArgs e)
{
  Database database = new Database(ApplicationData.Current.LocalFolder, "usertask .db");

  await database.OpenAsync();

  string query = "INSERT INTO TASKS (Task) VALUES (@task)";
  Statement statement = await database.PrepareStatementAsync(query);
  statement.BindTextParameterWithName("@task", "Work on CodeProject Article");
       
  await statement.StepAsync();
}

Below is the code block to retrieve task information from the SQLite Tasks table.

private async void FetchTasksButtonClicked(object sender, RoutedEventArgs e)
{
  Database database = new Database(ApplicationData.Current.LocalFolder, "usertask .db");
  await database.OpenAsync();
  string query = "SELECT * FROM TASKS";
  Statement statement = await database.PrepareStatementAsync(query);
  while (await statement.StepAsync())
  {
      MessageBox.Show(statement.GetTextAt(0));
  }
} 

Points of Interest

It wasn't so easy or straightforward to make use of the SQLite library in Windows Phone. After doing some research on the topic I learned how to make use of it with no trouble. Hope my findings will help others too.

SQLite for Windows Phone 8

SQLite for Windows Phone 8 Posted on 22-03-2014  In this tutorial we will see with an example how to use SQLite in Windows Phone 8. Note: this tip is just an introduction about the usage of the SQLite library in Windows Phone 8. 1.1428571428571/10 1977

Comment:

To comment you must be logged in members.

Files with category

  • Creating a Virtual Windows Phone 8 Development Environment

    View: 1919    Download: 0   Comment: 0   Author: none  

    Creating a Virtual Windows Phone 8 Development Environment

    Category: Windows phone
    Fields: Other

    0/4 review
    Like me, many developers didn't want to switch Operating Systems to develop for Windows 8 and Windows Phone 8 (WP8). After following the instructions in this tip, if you are one of these developers, you will be able to start developing for WP8 while...

  • Windows Phone WebBrowser control: Manipulating Page DOM

    View: 2616    Download: 0   Comment: 0   Author: none  

    Windows Phone WebBrowser control: Manipulating Page DOM

    Category: Windows phone
    Fields: Other

    0.64285714285714/7 review
    If you've programmed for Desktop (Windows Forms), you should know that WebBrowser control has a property called Document (of type HtmlDocument). This property allows us to manipulate the DOM of the page. However, that property does not exist in...

  • A Simple Guide To Mobile Phone File Transferring

    View: 2343    Download: 0   Comment: 0   Author: none  

    A Simple Guide To Mobile Phone File Transferring

    Category: Windows phone
    Fields: Other

    0.9/5 review
    With the extensive development of the mobile phone industry, our mobile phones are becoming more powerful than before. Today, mobile phones can process pictures, sound, and even video. We can get pictures from a phone's camera, or download them...

  • How to Publish your Windows Phone 8 Application on the Store

    View: 1335    Download: 0   Comment: 0   Author: none  

    How to Publish your Windows Phone 8 Application on the Store

    Category: Windows phone
    Fields: Computers - Technology

    1.5/3 review
    Almost of my friends asked me how to publish my Windows Phone 8 application on the store and this process can take time because your application must meet all the store requirements. So, in this tip, we will see together how to publish a Windows...

  • Air hockey

    View: 785    Download: 0   Comment: 0   Author: none  

    Air hockey

    Category: Windows phone
    Fields: Computers - Technology

    0/6 review
    Introduction Have you ever played Air Hockey? Air Hockey is a fairly popular game in game centers and other places where people hang out. Not that many people had a chance to try it as a pre-installed game on operating systems. The purpose of the...

  • Pairs game

    View: 458    Download: 0   Comment: 0   Author: none  

    Pairs game

    Category: Windows phone
    Fields: Computers - Technology

    0/1 review
    Introduction Pairs, also known as Concentration, Memory cards, Pexeso etc. is a simple card game, where player must find two identical cards. This game is great for memory training and good to kill some time for kids and adults. Nevertheless, our...

  • Snake game for tablets and Smartphones

    View: 928    Download: 1   Comment: 0   Author: none  

    Snake game for tablets and Smartphones

    Category: Windows phone
    Fields: Computers - Technology

    0/9 review
    Introduction The Snake game is a well-known game for mobile devices. The first time Snake made its debut was in 1997 and people usually know the game from Nokia 6110. Since then, this game changed many times and now it is time to adjust it for...

  • Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    View: 1197    Download: 0   Comment: 0   Author: none  

    Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    Category: Windows phone
    Fields: Computers - Technology

    1/4 review
    If you've tried using a DataContractJsonSerializer or a DataContractSerializer with Push Notification for the Windows Phone, you may have experienced an ArgumentNullException during deserialization. This can happen because the MemoryStream is...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd