Increase in data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getwritabledatabase ();
2, execute the SQL statement, to achieve the increase of data
Db.execsql ("INSERT into person (name,number) VALUES (?,?)", new object[] {name, number});
3. Close the database
Db.close ();
Deletion of data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getwritabledatabase ();
2, execute the SQL statement, to implement the data modification
Db.execsql ("Delete from person where name=?", new object[] {name});
3. Close the database
Db.close ();
Modification of data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getwritabledatabase ();
2, execute the SQL statement, to implement the data modification
Db.execsql ("Update person set number=?") Where Name=? ", new object[] {newnumber, name});
3. Close the database
Db.close ();
Query for Data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getreadabledatabase ();
2. Call the Rawquery method in the Help class of the SQLite database to query the data
cursor cursor = db.rawquery ("select * from person where name=?", new string[] {name});
3. Querying all data in the database
Boolean result = Cursor.movetonext ();
4. Close the wiper project
Cursor.close ();
5. Close the database
Db.close ();
6. Returns whether there are any results in the database that need to be queried
return result;
Using SQL statements to manipulate databases in Android