标签:
增:insert into 表名 (字段名,字段名) values (?,?,?)
删:delete from 表名 where 字段=?
改:update 表名 set 字段=?,字段=? where 条件=?
查:select * form 表名 where 字段=?
(*可以更改为想要查找的内容)
创建数据库
| package com.bawei.zsgcactivity; import android.content.Context; public class MySqlistHelper extends SQLiteOpenHelper{     public MySqlistHelper(Context context, String name, CursorFactory factory,     @Override }     @Override } | |
主方法调用
MySqlistHelper helper=new MySqlistHelper(this, "07a", null, 1);
SQLiteDatabase   dp = helper.getReadableDatabase();
查询
| Cursor c = dp.rawQuery("select * from good", null); | |
修改
| MySqlistHelper  helper=new MySqlistHelper(Xiougai.this, "07a", null, 1);
              dp = helper.getReadableDatabase();
             dp.execSQL("update good set name=?,price=?,producter=?,color=? where id=?", new Object[]{name1,price1,producter1,color1,id});  | |
增加
dp.execSQL("insert into good values(null,?,?,?,?)", new Object[]{name,price,producter,color});
删除
dp.execSQL("delete from good where id=?", new Object[]{list.get(position).getId()});
标签:
原文地址:http://www.cnblogs.com/nanze/p/5384498.html