This is also achieved through Android Juint.
Based on the last project continued, the last project Portal: "Android–android juint and Sqlite" http://www.cnblogs.com/yydcdut/p/3790579.html
Update Database
public Personsqlite (context context) {super (context, "person.db", null , 2 ); // TODO auto-generated constructor stub } @Override public void ONUPGR Ade (Sqlitedatabase db, int oldversion, int NewVersion) { // TODO Auto-generated method stub System.out.println ("The database has changed!! "); Db.execsql ( ALTER TABLE person add account varchar () ); }
SQL processing Classes
Public LongAddmoney (string name, string number,intMoney ) {Sqlitedatabase db=sqlite.getwritabledatabase (); //Db.execsql ("INSERT into person (name,number) VALUES (?,?)", New Object[]{name,number});Contentvalues values =Newcontentvalues (); Values.put ("Name", name); Values.put ("Number", number); Values.put ("Account", Money); Longid = db.insert ("Person",NULL, values); Db.close (); returnID; }
Test
//Add Data First Public voidTestaddmoney () {PersonDao2 DAO=NewPersonDao2 (GetContext ()); Dao.addmoney ("Wangwu", "123", 5000); Dao.addmoney ("Zhangsan", "321", 2000); } //Transaction Processing Public voidtesttransaction () {Personsqlite SQLite=NewPersonsqlite (GetContext ()); Sqlitedatabase DB=sqlite.getwritabledatabase (); Db.begintransaction (); Db.execsql ("Update person set account=account-1000 where name =?",Newobject[]{"Zhangsan"}); Db.execsql ("Update person set account=account+1000 where name =?",Newobject[]{"Wangwu"}); Db.endtransaction (); Db.close (); }
I'm the dividing line of the king of the Land Tiger.
Source code: HTTP://PAN.BAIDU.COM/S/1DD1QX01
Sqlite2.zip
Reprint Please specify source: Http://www.cnblogs.com/yydcdut