Skip to main content

Android SQLite Database 1

Using Android Studio Crating a Database (SQLite)

1. NEW PROJECT
2.CREATE  A CLASS NAME CALL (DB.class)
3.import SQLiteDatabase
   import SQLiteOpenHelper

SCREEN SHOT OF CODE (IMAGE)


CODE (TEXT) Bellow

package com.example.rimzan.j2program;
import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteOpenHelper;

public class DB extends SQLiteOpenHelper {

    public static final String DATABASE_NAME="Student.db";    public static final String TABLE_NAME="Student_Table",            COL_1="ID",COL_2="NAME",COL_3="SURENAME",COL_4="MARKS";
    public DB(Context context) {
        super(context, DATABASE_NAME,null,1);        SQLiteDatabase db=getWritableDatabase();    }

    @Override    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE "+TABLE_NAME+" (ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
                "NAME TEXT, SURENAME TEXT, MARKS INTEGER)");    }

    @Override    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME+ "");        onCreate(db);    }
}

Comments

Popular posts from this blog

Micro Loan Banking Management System

Ministry of Higher Education Project : SLIATE (live project)

ABOUT SLIATE Our Mission  "Creating Excellent Higher National and National Diplomates with Modern Technology for Sustainable Development" Our Vision "To Become the Centre of Excellence in Technological Education" As per the recommendations of the Committee appointed by Prof. Wiswa Waranapala, Deputy Minister of Higher Education in 1994, the Sri Lanka Institute of Advanced Technical Education (SLIATE) was formed in 1995, under the Sri Lanka Institute of Advanced Technical Education Act No. 29 of 1995, In 2001 the name of the institution was amended as Sri Lanka Institute of Advanced Technological Education, (SLIATE). It functions as an autonomous Institute for the management of Higher National and National Diploma courses. The main purposes of establishing SLIATE were to reform and restructure the entire technical and vocational education system in relation to the changing needs of economic development, to meet manpower requirements of natio...

Variables in PHP

A variable is a storage area. You put things into your storage areas (variables) so that you can use and manipulate them in your programmers. Things you'll want to store are numbers and text. Variable in PHP You can't begin their names with an underscore (_), or a number. But most other characters are fine. Example 1 : A person is going to be collecting the books. But we can specify how many books he will be collecting. If you have five books   to give him, then you do the "Answer"   is like this: Answer is = 5 Books Ok, now going to the subject …   you're studying   PHP, so there's something missing. Two things, actually. First, your people (variables) need a dollar sign at the beginning (people are like that). So it would be this: $ books = 10 Examples 2 : try to do $books=10+20+30; What is your answer : answer must be 60 Example 3 : Test your mind Find the total books ? $english_book=10; ...