@Override
public boolean SaveProductData(Model model) {
// 创建数据库帮助类
DBHelper helper = new DBHelper(MainActivity.this);
// 打开数据库
helper.openDatabase();
// 把user存储到数据库里
long result = helper.insert(model);
// 通过结果来判断是否插入成功,若为1,则表示插入数据失败
if((int) result == -1)
{
Toast.makeText(this, "添加失败!!!", Toast.LENGTH_LONG).show();
return false;
}
else
{
Toast.makeText(this, "添加成功!!!", Toast.LENGTH_LONG).show();
return true;
}
}
@Override
public ArrayList<HashMap<String, Object>> GetProductList() {
// TODO Auto-generated method stub
// 创建数据库帮助类
DBHelper helper = new DBHelper(MainActivity.this);
// 打开数据库
helper.openDatabase();
return helper.getAllUser();
}
其实数据库简单运用就这么回事,简而言之,就是增删改差加调用。