1.sqlite
It's a database that Android uses to manage data, lightweight and efficient.
View and manage SQLite databases in Android
Http://www.cnblogs.com/walkingp/archive/2011/03/28/1997437.html
2.SQLiteOpenHelper class ( abstract class )
It is used to create, open the database. That is, to manage the SQLite database, note: It is an abstract class that requires an inheritance implementation
Construction method: Factory is generally null, it can create/open/Manage Database
Sqliteopenhelper (context context, String name, sqlitedatabase.cursorfactory Factory, int version)
Member Methods:
Sqlitedatabase getreadabledatabase ();//create and/or open a database and can only read
sqlitedatabase getwritabledatabase ()//create and/or open a database and can read or write operations.
oncreate (Sqlitedatabase db) ;//Called when The database is created for the first time.
Onupgrade (sqlitedatabase db, int oldversion, int newversion);//called when the database needs Graded.
3.SQLiteDatabase class
Database classes, which are used to manage databases, can use SQL statements.
it needs to be created using the Sqliteopenhelper getreadabledatabase () method or the getwritabledatabase () method, as long as both methods are created.
Member Methods:
execsql (String sql) ;//eg:db.execsql ("CREATE table user (ID int,name varchar (20))")
Insert (String table, string nullcolumnhack, contentvalues values);//Insert Method
< Span class= "Apple-converted-space" > update (string< Span class= "Apple-converted-space" > table, contentvalues values, string whereclause, string[] whereargs)
< Span class= "Apple-converted-space" >< Span class= "Sympad" > //eg: db.update ("User", Values, "id=", New string[]{"1"});
The first parameter is the name of the table to be updated, the second argument is a Contentvaleus object, The third parameter is the WHERE clause
Delete (string table, string whereclause, string[] Whereargs);//Delete method
Query operation:
classQuerylistenerImplementsonclicklistener{@Override Public voidOnClick (View v) {System.out.println ("AAA------------------"); LOG.D ("Mydebug", "myfirstdebugmsg"); Databasehelper DBHelper=NewDatabasehelper (sqliteactivity. This, "test_mars_db"); Sqlitedatabase DB=dbhelper.getreadabledatabase (); Cursor Cursor= Db.query ("User",Newstring[]{"id", "name"}, "Id=?",Newstring[]{"1"},NULL,NULL,NULL); while(Cursor.movetonext ()) {String name= Cursor.getstring (Cursor.getcolumnindex ("name")); System.out.println ("Query--->" +name); } } }
Android-sqlite Database < five >