Increase in data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getwritabledatabase ();
2. Create a class contentvalues like the map collection to store key-value pairs
Contentvalues values = new Contentvalues ();
3, the need to increase the data to be stored in
Values.put ("name", name);
Values.put ("number", number);
4, the implementation of system-provided API data to increase the interface
Long id = db.insert ("person", null, values);
5. Close the database
Db.close ();
6. Returns the location of the added entry in the database
return ID;
Deletion of data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getwritabledatabase ();
2, the implementation of system-provided API data removal interface
int id = db.delete ("Person", "Name=?", new string[] {name});
3. Close the database
Db.close ();
4. Returns the location of the added entry in the database
return ID;
Deletion of data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getwritabledatabase ();
2. Create a class contentvalues like the map collection to store key-value pairs
Contentvalues values = new Contentvalues ();
3, the need to increase the data to be stored in
Values.put ("number", Newnumber);
4, the implementation of system-provided API data removal interface
int id = db.update ("Person", values, "Name=?", new string[] {name});
5. Close the database
Db.close ();
6. Returns the location of the deleted entry in the database
return ID;
Query for Data
1. Create a Help class for SQLite data
Sqlitedatabase db = Helper.getreadabledatabase ();
2, the implementation of the system provides API data query interface
cursor cursor = db.query ("person", NULL, "Name=?", new string[] {name}, NULL, NULL, NULL);
3. Querying all data in the database
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 the system to provide API data access interface operations database in Android