表创建好了,需要插入数据了,
我们下边演示3中方法插入数据
给主界面上添加一个按钮,点击按钮执行插入信息操作
方法一
String insertsql="insert into Student(name,age,address)values('feng',20,'xian')"; msqliteDatabase.execsql(insertsql);
方法二
String name="李四";
int age =21;
String address="北京";
// String insertsql="insert into Student(name,'xian')"; String insertsql="insert into Student(name,address)values('"+name+"',"+age+",'"+address+"')"; msqliteDatabase.execsql(insertsql);
方法三
String insertsql="insert into Student(name,address)values(?,?,?)";
Object[]objs=new Object[]{"刘",18,"a"};
msqliteDatabase.execsql(insertsql,objs);