Java Code Examples for com.lidroid.xutils.db.sqlite.WhereBuilder

The following examples show how to use com.lidroid.xutils.db.sqlite.WhereBuilder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: qingyang   Source File: DBManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 删除上传信息
 * 
 * @param uploadfilepath
 * @return
 */
public boolean delUpload(String uploadfilepath) {

	Selector selector = Selector.from(Upload.class);

	selector.where(WhereBuilder.b("uploadfilepath", "=", uploadfilepath));

	try {
		Upload upload = db.findFirst(selector);

		db.delete(upload);
	} catch (DbException e) {
		e.printStackTrace();
		return false;
	}
	return true;
}
 
Example 2
Source Project: qingyang   Source File: DBManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取上传资源Id
 * 
 * @param uploadfilepath
 * @return
 */
public String getBindId(String uploadfilepath) {

	Selector selector = Selector.from(Upload.class);

	selector.where(WhereBuilder.b("uploadfilepath", "=", uploadfilepath));

	String bindId = "";

	try {
		Upload upload = db.findFirst(selector);

		if (upload == null) {
			return "";
		}
		bindId = upload.getSourceid();
	} catch (DbException e) {
		e.printStackTrace();
		return "";
	}
	return bindId;
}
 
Example 3
Source Project: QiQuYing   Source File: DingCaiDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 检查是否点过赞
 * @param userId
 * @param jokeId
 * @return
 */
public DingOrCai getDingOrCai(int userId, int jokeId) {
	DbUtils db = DbUtils.create(context);
	DingOrCai dingOrCai = null;
	try {
		dingOrCai = db.findFirst(Selector.from(DingOrCai.class).where(WhereBuilder.b("user_id", "=", userId).and("joke_id", "=", jokeId)));
		Log.d(TAG, "getDingOrCai success");
	} catch (DbException e) {
		Log.d(TAG, "getDingOrCai failure", e);
	}
	return dingOrCai;
}
 
Example 4
Source Project: QiQuYing   Source File: DingCaiDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 查找未同步到服务器的点赞数据
 * @return
 */
public List<DingOrCai> getUnUpload() {
	DbUtils db = DbUtils.create(context);
	List<DingOrCai> dbModels = null;
	try {
		dbModels = db.findAll(Selector.from(DingOrCai.class).where(WhereBuilder.b("is_upload", "=", DingOrCai.NOT_UPLOAD)));
		Log.d(TAG, "getUnUpload success");
	} catch (DbException e) {
		Log.d(TAG, "getUnUpload failure", e);
	}
	return dbModels;
}
 
Example 5
Source Project: QiQuYing   Source File: CollectDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 检查是否收藏过
 * @param userId
 * @param jokeId
 * @return
 */
public Collect getCollect(int userId, int jokeId) {
	DbUtils db = DbUtils.create(context);
	Collect collect = null;
	try {
		collect = db.findFirst(Selector.from(Collect.class).where(WhereBuilder.b("user_id", "=", userId).and("joke_id", "=", jokeId)));
		Log.d(TAG, "getDingOrCai success");
	} catch (DbException e) {
		Log.e(TAG, "getDingOrCai failure", e);
	}
	return collect;
}
 
Example 6
Source Project: QiQuYing   Source File: CollectDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 取消收藏
 * @param jokeId
 */
public void cancelCollect(int jokeId) {
	DbUtils db = DbUtils.create(context);
	try {
		db.delete(Collect.class, WhereBuilder.b("joke_id", "=", jokeId));
		Log.d(TAG, "cancelCollect success");
	} catch (DbException e) {
		Log.e(TAG, "cancelCollect failure", e);
	}
}
 
Example 7
Source Project: QiQuYing   Source File: CollectDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取我的收藏
 * @param userId
 * @return
 */
public List<Collect> getCollects(int userId) {
	DbUtils db = DbUtils.create(context);
	List<Collect> dbModels = null;
	try {
		dbModels = db.findAll(Selector.from(Collect.class).
				where(WhereBuilder.b("user_id", "=", userId))
				.orderBy("create_at", true));
		Log.d(TAG, "getCollects success");
	} catch (DbException e) {
		Log.e(TAG, "getCollects failure", e);
	}
	return dbModels;
}
 
Example 8
private void getDateFromDateBaseAndInitDate() {
	String uid = spf.getString("Uid", "");
	String did = device.getDid();
	try {
		scheduleDates.clear();
		scheduleDates = dbUtils.findAll(
				Selector.from(GosScheduleData.class).where("uid", "=", uid).and(WhereBuilder.b("did", "=", did)));
	} catch (DbException e) {
		e.printStackTrace();
	}
	for (GosScheduleData i : scheduleDates) {
		i.setViewContent();
	}
}
 
Example 9
Source Project: android-open-project-demo   Source File: DbFragment.java    License: Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.db_find)
public void find(View view) {
	try {
		String temp = "";
		// 查找全部
		// List<Student> students = db.findAll(Student.class);
		// for (Student student : students) {
		// temp = temp + student.toString() + "\n";
		// }

		// 主键查找
		// Student student = db.findById(Student.class, 10086);
		// temp = student.toString();

		//条件查找
		List<Student> students = db.findAll(Selector.from(Student.class)
				.where("name", "=", "李四")
				.where(WhereBuilder.b("id", "=", 10010)).orderBy("name").limit(0).offset(10));
		if (students == null) {
			Toast.makeText(this.getActivity(), "没有数据请先添加数据", Toast.LENGTH_SHORT).show();
			return;
		}
		for (Student student : students) {
			temp = temp + student.toString() + "\n";
		}
		info.setText(temp);
	} catch (DbException e) {
		e.printStackTrace();
	}
}