StudentDAOTest2.java
private static final String TAG = "StudentDAOTest";
public void testAdd() {
StudentDAO2 studentDAO2=new StudentDAO2(this.getContext());
Student student=new Student(3,"huanglw",(short)20);
studentDAO2.add(student);
Log.i(TAG,"add successed");}
StudentDAOT.java
/** * 添加学生信息StudentDAO2 * @param student */public void add(Student student){db=dbHelper.getWritableDatabase();ContentValues contentValues=new ContentValues();contentValues.put("sid",student.getSid());contentValues.put("sname",student.getSname());contentValues.put("sage",student.getSage());db.insert("t_student","sid",contentValues);}
原文链接:https://www.f2er.com/sqlite/202608.html