SQLite is a lightweight embedded database, sqlite consumption of resources is very low, in the embedded device may be as long as hundreds of K of memory. Faster than MySQL or Postgre.
Note that SQLite does not belong to the client-server model database, its engine will be connected to the program as a part of it, so there is no db such as MySQL, need to be a communication protocol and database instance interaction.
It is API execution for SQLite. and the entire database, including definitions, tables, indexes, and data are stored in a single file.
in this design, SQLite, which supports transactions, locks the entire data file when it executes a transaction. Here is a basic example of a program:
db = Openorcreatedatabase (db_name, This. Mode_private,NULL); Db.execsql ("DROP TABLE IF EXISTS users"); Db.execsql ("CREATE TABLE IF not EXISTS users (_id INTEGER PRIMARY KEY autoincrement, username varchar, password varchar)"); Db.execsql ("INSERT into Users VALUES (NULL, ' Fredric ', ' Fredricpassword ')"); Contentvalues CV=Newcontentvalues (); Cv.put ("username", "Sinny"); Cv.put ("Password", "Sinnypassword"); Db.insert ("Users",NULL, CV); Cursor Cursor= Db.rawquery ("SELECT * from users",NULL); while(Cursor.movetonext ()) {log.i (tag_activity, cursor.getstring (Cursor.getcolumnindex ("Username"))); LOG.I (Tag_activity, Cursor.getstring (Cursor.getcolumnindex ("Password"))); } cursor.close ();
Print output: Fredric, Fredricpassword, Sinny, Sinnypassword
SQLite (1, Basic)