- void AddEmployee(Employee emp)
- {
- SQLiteDatabase db= this.getWritableDatabase();
- ContentValues cv=new ContentValues();
- cv.put(colName, emp.getName());
- cv.put(colAge, emp.getAge());
- cv.put(colDept, emp.getDept());
- //cv.put(colDept,2);
- db.insert(employeeTable, colName, cv);
- db.close();
- }
- int getEmployeeCount()
- {
- SQLiteDatabase db=this.getWritableDatabase();
- Cursor cur= db.rawQuery("Select * from "+employeeTable, null);
- int x= cur.getCount();
- cur.close();
- return x;
- }
- //该片段来自于http://www.codesnippet.cn/detail/241220121143.html
来源: http://www.codesnippet.cn/detail/241220121143.html