上图可以看出一般用数据库的是mysql,但有时可能遇到一些情况:可能开发的项目不需要太多的数据存储而指定一些功能的实现而SQLite不需要管理,在不需要数据库管理员支持的场景下工作良好,并且效率更高.
下面为一些基本的使用方法
创建数据库
public class MySQLite extends SQLiteOpenHelper { public MySQLite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version);} }
增加数据值
writaDb.execSQL(“insert into 表名 (字段名) values(值)”);\
删除数据
writaDb.execSQL(“delete from 表名 where id=条件值”);
修改数据
writaDb.execSQL(“update 表名 set(字段名) values(值)where id=1”
查找数据
Cursor cursor = writaDb.rawQuery("select t_id from teacher where t_id = “2”, null); while(cursor.moveToNext()){ String name=cursor.getString(cursor.getColumnIndex("Pwd"));}
继承SQLit