|TEXT||It is similar to String in Java.|
|INTEGER||It is similar to Long in Java.|
|REAL||It is similar to Double in Java.|
|Package||The android.database.sqlite is the main package in Android SQLite which contains the classes to manage your own databases.|
|Creation||The openOrCreateDatabase() method is called for creating a database with your database name and mode as a parameter.|
This method returns an instance of SQLite database.
SQLiteDatabse mydatabase = openOrCreateDatabase (“database_name”, MODE_PRIVATE, null);
|Insertion||The execSQL() method is used to insert the data into table. This method is defined in SQLiteDatabse class.|
execSQL(String SQL, Object bind Args)
The execSQL() method is used not only to insert a data, but also to update or modify the existing data in database, using bind arguments.
mydatabase.execSQL(“CREATE TABLE TutorialRide(Admin_name VARCHAR, Password VARCHAR);”);
mydatabase.execSQL(“INSERT INTO TutorialRide VALUES('ABC', '123');”);
|Fetching||An object of the Cursor class is used to fetch the data from the database. Calling a method of Cursor class is called rawQuery which returns a resultset with the cursor pointing to the table.|
The rawQuery() accepts an SQL SELECT statement as an input.
Cursor resultset = mydatabase.rawQuery(“SELECT * FROM Employee”, null);
String eid = resultset.getString(1);
String ename = resultset.getString(2);
|SQLiteOpenHelper Class||This class is used for creating a database and version management.|
In this class, there are two methods which need to override for creating and updating the database, they are onCreate() and onUpgrade().
If the database is accessed but not yet created then onCreate() method is called by the framework.
If the database version is increased in your application code then onUpgrade() method is called. It allows to modify the exisitng database.
The SQLiteOpenHelper class provides the getReadableDatabase() and getWriteableDatabase() methods to get access to an SQLiteDatabase object.