每日汇报
学习增删改查
学习成果:
添加一行数据
首先创建JavaBean(对应为Bmob后台的数据表,更详细的解释请查看Android开发文档)
public class Person extends BmobObject {
private String name;
private String address;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
添加数据
Person p2 = new Person();
p2.setName("lucky");
p2.setAddress("北京海淀");
p2.save(new SaveListener<String>() {
@Override
public void done(String objectId,BmobException e) {
if(e==null){
toast("添加数据成功,返回objectId为:"+objectId);
}else{
toast("创建数据失败:" + e.getMessage());
}
}
});