Written in front of, this article Reprinted from http://www.eoeandroid.com/thread-82030-1-1.html
Public void Delete (integer... IDS) {If (IDs. length> 0) {stringbuilder sb = new stringbuilder (); string [] strids = new string [IDs. length]; for (INT I = 0; I <IDs. length; I ++) {sb. append ('? '). Append (','); strids [I] = string. valueof (IDs [I]);} sb. deletecharat (sb. length ()-1); sqlitedatabase database = dbmanger. getwritabledatabase (); // parameter table name specifies the condition placeholder value database. delete ("person", "personid in (" + Sb + ")", strids) ;}} public list getscrolldata (INT startresult, int maxresult) {list persons = new arraylist (); sqlitedatabase database = dbmanger. getwritabledatabase (); // parameter table name returned field specified condition ing value grouping Condition Whether to sort the paging condition cursor = database. query ("person", new string [] {"personid", "name", "Age"}, null, "personid DESC ", startresult + "," + maxresult); While (cursor. movetonext () {persons. add (new person (cursor. getint (0), cursor. getstring (1), cursor. getshort (2);} return persons;} public long getcount () {sqlitedatabase database = dbmanger. getwritabledatabase (); cursor = database. query ("P Erson ", new string [] {" count (*) "}, null, null); If (cursor. movetonext () {return cursor. getlong (0) ;}return 0 ;}} package EOE. demo; import Java. util. arraylist; import Java. util. list; import it. bean. person; import android. content. contentvalues; import android. content. context; import android. database. cursor; import android. database. SQLite. sqlitedatabase;/*** this class does not need to add, query, modify, and delete SQL statements * But sqlitedataba The se object is the **/public class personsqlservice {private mangerdatabase dbmanger; Public personsqlservice (context) {dbmanger = new mangerdatabase (context );} public void save (person) {sqlitedatabase database = dbmanger. getwritabledatabase (); contentvalues values = new contentvalues (); values. put ("name", person. getname (); values. put ("Age", person. getage (); // name of the parameter table to construct the correct field ing of the insert statement Database. insert ("person", "name", values);} public void Update (person) {sqlitedatabase database = dbmanger. getwritabledatabase (); contentvalues values = new contentvalues (); values. put ("name", person. getname (); values. put ("Age", person. getage (); // parameter table name updates the placeholder value of the ing relationship condition database. update ("person", values, "personid =? ", New string [] {string. valueof (person. getpersonid ()});} public person find (integer ID) {sqlitedatabase database = dbmanger. getwritabledatabase (); // execute the query parameter. The fields returned by the table name specify the condition and specify whether the condition values are grouped or not. query ("person", new string [] {"personid", "name", "Age"}, "personid =? ", New string [] {string. valueof (ID)}, null); If (cursor. movetonext () {return new person (cursor. getint (0), cursor. getstring (1), cursor. getshort (2);} return NULL ;}