Android using SQL to operate the database

Use SQL to manipulate the database

The method of adding data is as follows:

db.execSQL(“insert into Book (name,author,pages,price) values(?,?,?,?)”,new String[] {“The Da Vinci Code”,“Dan Brown”,“454”,“16.96”});

The method of updating data is as follows:

db.execSQL(“update Book set price = ? where name = ?”,new String [] {“10.99”,“The Da Vinci Code”});

The method of deleting data is as follows:

db.execSQL(“delete from Book where pages > ?”,new String []{“500”});

The method of querying data is as follows:

db.rawQuery(“select * from Book”,null);

Guess you like

Origin blog.csdn.net/i_nclude/article/details/77622206