Android in-depth study of SQLite instances (7)

Source: Internet
Author: User
Tags psql
Package EOE. demo; import Java. util. list; import it. bean. person; import it. service. personservice; import android. test. androidtestcase; import android. util. log;/***** run the personservice test **/public class personservicetest extends androidtestcase {Private Static final string tag = "personservicetest"; Public void testsave () throws exception {personservice = new personservice (this. getcontext (); For (INT I = 0; I <10; I ++) {personservice. save (new person ("huhuanhuan", (short) 33) ;}} public void testfindbyid () {personservice = new personservice (this. getcontext (); person P = personservice. findbyid (1); log. I (TAG, P. tostring ();} public void testupdate () {person = new person (1, "Chun", (short) 20); personservice = new personservice (this. getcontext (); personservice. update (person); person P = personservice. findbyid (1); log. I (TAG, P. tostring ();} public void testgetdateperson () {person P = new person (); personservice = new personservice (this. getcontext (); List list = personservice. getdateperson (0, 10); For (INT I = 0; I <p> P = (person) list. get (I); log. I (TAG, P. tostring () ;}} public void testgetcount () {personservice = new personservice (this. getcontext (); long l = personservice. getcount (); log. I (TAG, String. valueof (l);} public void testdelete () {personservice = new personservice (this. getcontext (); personservice. delete (1, 2, 3 );}}

Test code

Package EOE. demo; import Java. util. list; import it. bean. person; import it. service. personsqlservice; import android. test. androidtestcase; import android. util. log;/*** run personsqlservice for testing **/public class personsqlservicetest extends androidtestcase {Private Static final string tag = "personsqlservicetest"; Public void testsave () {personsqlservice Psql = new personsqlservice (this. getcontext (); For (INT I = 0; I <10; I ++) {Psql. save (new person ("Li Yuan", (short) 1) ;}} public void testfind () throws exception {personsqlservice Psql = new personsqlservice (this. getcontext (); person = Psql. find (22); log. I (TAG, person. tostring ();} public void testupdate () throws exception {personsqlservice Psql = new personsqlservice (this. getcontext (); person = Psql. find (1); person. setname ("liming"); Psql. update (person); // log. I (TAG, person. tostring ();} public void testgetcount () throws exception {personsqlservice Psql = new personsqlservice (this. getcontext (); log. I (TAG, String. valueof (Psql. getcount ();} public void testgetscrolldata () throws exception {personsqlservice Psql = new personsqlservice (this. getcontext (); list persons = Psql. getscrolldata (0, 20); For (person: Persons) {log. I (TAG, person. tostring () ;}} public void testdelete () throws exception {personsqlservice Psql = new personsqlservice (this. getcontext (); Psql. delete (1, 2, 3 );}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.