SQLite 数据库是 Android 平台上默认的数据库引擎。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
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; } |