SQLiteDatabase (Without SqliteOpenHelper class)
SQLite is a open-source relational database, that is used to perform database operations such as creating, storing, manipulating, retrieving and deleting data from the database. SQLitedatabase is used in android in two way: Using SQLiteOpenHelper class Without SQLiteOpenHelper class Here we are going to see the example of sqlitedatabase without SQLiteOpenHelper class. In this example, we will do following: Create a database Create a table Insert values into table Retrieve values Update values Delete values Create a database: SQLiteDatabase db=openOrCreateDatabase(DB_NAME, Context.MODE_PRIVATE, null); This opens a database defined in the constant DB_NAME, if it already exists. Else it creates a new database and open it. Create a table: db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, DESIGNATION TEXT, CONTACT NUMBER, AREA TEXT, CITY TEXT);"); This creates
Comments
Post a Comment