Android Sqllite operation

by mariganesh 2013-07-05 18:16:13

Android Sqllite operation

Here we can studied about how to create database and table in sqllite and also how to fetch data from sqllite in android



Create Database

Use this code for create the database in android


SQLiteDatabase dbe = SQLiteDatabase.openDatabase("/data/data/com.Comapanyname.Prjectname/databases/dbname.db", null,0);


Create Table

Use this code for create the table in android


SQLiteDatabase dbe = SQLiteDatabase.openDatabase("/data/data/com.Comapanyname.Prjectname/databases/dbname.db", null,0);

dbe.execSQL("CREATE TABLE IF NOT EXISTS userdetails(name TEXT, uid TEXT ,mailid TEXT,status TEXT)");



Fetch Data from Sqllite Table

Use this code for fetching data from table in android


SQLiteDatabase dbe = SQLiteDatabase.openDatabase("/data/data/com.Comapanyname.ProjectName/databases/dbname.db", null,0);

Cursor crstatus = null;

crstatus = dbe.rawQuery("SELECT status FROM userdetails", null);
crstatus.moveToFirst();
while(!crstatus.isAfterLast())
{

String cname = crstatus.getString(crstatus.getColumnIndex("name"));
String cidd = crstatus.getString(crstatus.getColumnIndex("uid"));
crstatus.moveToNext();
}
604
like
0
dislike
0
mail
flag

You must LOGIN to add comments