表创建好了,需要插入数据了,
我们下边演示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,age,address)values('feng',20,'xian')";
String insertSql="insert into Student(name,age,address)values('"+name+"',"+age+",'"+address+"')";
mSQLiteDatabase.execSQL(insertSql);
方法三
String insertSql="insert into Student(name,age,address)values(?,?,?)";
Object[]objs=new Object[]{"刘",18,"a"};
mSQLiteDatabase.execSQL(insertSql,objs);