Showing posts with label android SQLite. Show all posts
Showing posts with label android SQLite. Show all posts

Tuesday, 28 January 2014

How to avoid duplicate's insertion into android SQLite data base?


The UNIQUE constraint uniquely identifies each record in a database table.

The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns.

A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it.

Note that you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.

SQL UNIQUE Constraint on CREATE TABLE
The following SQL creates a UNIQUE constraint on the "P_Id" column when the "Persons" table is created:

Query

CREATE TABLE Persons
(
P_Id int NOT NULL UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)

Friday, 1 February 2013

SQLiteManager plugin for eclipse - Android


In Eclipse IDE You can see the sqlite database(.db file) in eclipse by opening File Explorer.

Steps to open File Explorer.

Window/Show View/File Explorer

Screenshot










Then to  /data/data/package_name/databases folder

But here we cannot see the tables and table data.

For viewing the table details in Eclipse,you have to include a one plugin to your Eclipse IDE .

Plug in Process

first you can download the jar from below.

Download the jar from the sqlite manager from here.
Click Here

Now Place the jar in the folder Eclipse plugins folder (e.g. /usr/lib/eclipse/plugins)

Now Restart the eclipse and now you can see the SqLiteManger plugin on the top right of the File Explorer window.

Screenshot





By clicking the SqLiteManger icon, SqLiteManger Window comes and here we can see the table structure and table data.

Screenshot




NOTE: You can see Database file if the Database file extension should be .db

Android SQLite Database Viewer or Debuging with Stetho

Every Android Developer uses SQLite Database to store data into the Android Application data. But to view the data in SQLite have a lot of...