Java Code Examples for com.lidroid.xutils.db.sqlite.Selector
The following examples show how to use
com.lidroid.xutils.db.sqlite.Selector.
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 Author: zqingyang521 File: DBManager.java License: Apache License 2.0 | 6 votes |
/** * 删除上传信息 * * @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 Author: zqingyang521 File: DBManager.java License: Apache License 2.0 | 6 votes |
/** * 获取上传资源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: BigApp_Discuz_Android Author: BigAppOS File: EmojiDb.java License: Apache License 2.0 | 5 votes |
public static List<EmoticonBean> getEmojiGroup(Context context, String group) { DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null); try { return dbUtils.findAll(Selector.from(EmoticonBean.class).where("groupName", "=", group)); } catch (DbException e) { e.printStackTrace(); } return null; }
Example #4
Source Project: BigApp_Discuz_Android Author: BigAppOS File: EmojiDb.java License: Apache License 2.0 | 5 votes |
public static EmoticonBean getEmojiByUnicode(Context context, String unicode) { DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null); try { return dbUtils.findFirst(Selector.from(EmoticonBean.class).where("content", "=", unicode)); } catch (DbException e) { e.printStackTrace(); } return null; }
Example #5
Source Project: BigApp_Discuz_Android Author: BigAppOS File: EmojiDb.java License: Apache License 2.0 | 5 votes |
public static EmoticonBean getEmojiByShortname(Context context, String shortname) { DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null); try { return dbUtils.findFirst(Selector.from(EmoticonBean.class).where("shortname", "=", shortname)); } catch (DbException e) { e.printStackTrace(); } return null; }
Example #6
Source Project: BigApp_Discuz_Android Author: BigAppOS File: EmojiDb.java License: Apache License 2.0 | 5 votes |
public static List<EmoticonSetBean> getEmojiSetsByName(Context context, String name) { DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null); try { EmoticonSetBean setBean = dbUtils.findFirst(Selector.from(EmoticonSetBean.class).where("name", "=", name)); List<EmoticonBean> beans = getAllEmojis(context); setBean.setEmoticonList(beans); List<EmoticonSetBean> list = new ArrayList<EmoticonSetBean>(); list.add(setBean); return list; } catch (DbException e) { e.printStackTrace(); } return null; }
Example #7
Source Project: BigApp_Discuz_Android Author: BigAppOS File: EmojiDb.java License: Apache License 2.0 | 5 votes |
public static List<EmoticonSetBean> getEmojiLibraryByGroup(Context context, String name, String group) { DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null); try { EmoticonSetBean setBean = dbUtils.findFirst(Selector.from(EmoticonSetBean.class).where("name", "=", name)); List<EmoticonBean> beans = getEmojiGroup(context, group); setBean.setEmoticonList(beans); List<EmoticonSetBean> list = new ArrayList<EmoticonSetBean>(); list.add(setBean); return list; } catch (DbException e) { e.printStackTrace(); } return null; }
Example #8
Source Project: QiQuYing Author: liuling07 File: DingCaiDAO.java License: Apache License 2.0 | 5 votes |
/** * 检查是否点过赞 * @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 #9
Source Project: QiQuYing Author: liuling07 File: DingCaiDAO.java License: Apache License 2.0 | 5 votes |
/** * 查找未同步到服务器的点赞数据 * @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 #10
Source Project: QiQuYing Author: liuling07 File: CollectDAO.java License: Apache License 2.0 | 5 votes |
/** * 检查是否收藏过 * @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 #11
Source Project: QiQuYing Author: liuling07 File: CollectDAO.java License: Apache License 2.0 | 5 votes |
/** * 获取我的收藏 * @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 #12
Source Project: Gizwits-SmartBuld_Android Author: gizwits File: GosScheduleListActivity.java License: MIT License | 5 votes |
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 #13
Source Project: AndroidAppCodeFramework Author: Frank-Zhu File: DownloadManager.java License: Apache License 2.0 | 5 votes |
DownloadManager(Context appContext) { ColumnConverterFactory.registerColumnConverter(HttpHandler.State.class, new HttpHandlerStateConverter()); mContext = appContext; db = DbUtils.create(mContext); try { downloadInfoList = db.findAll(Selector.from(DownloadInfo.class)); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } if (downloadInfoList == null) { downloadInfoList = new ArrayList<DownloadInfo>(); } }
Example #14
Source Project: AndroidAppCodeFramework Author: Frank-Zhu File: DownloadManager.java License: Apache License 2.0 | 5 votes |
DownloadManager(Context appContext) { ColumnConverterFactory.registerColumnConverter(HttpHandler.State.class, new HttpHandlerStateConverter()); mContext = appContext; db = DbUtils.create(mContext); try { downloadInfoList = db.findAll(Selector.from(DownloadInfo.class)); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } if (downloadInfoList == null) { downloadInfoList = new ArrayList<DownloadInfo>(); } }
Example #15
Source Project: ALLGO Author: HsingPeng File: MyEventLogicImpl.java License: Apache License 2.0 | 5 votes |
@Override public void initEvent() { new AsyncTask<Void, Void, ArrayList<EventVo>>() { @Override protected ArrayList<EventVo> doInBackground(Void... params) { SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE); int uid = sharedPref.getInt("uid", -1) ; ArrayList<EventVo> events =new ArrayList<EventVo>(); try{ DbUtils db = DbUtils.create(context,uid + ".db"); db.configAllowTransaction(true); db.configDebug(true); List<EventVo> event = db.findAll(Selector.from(MyEventVo.class)); if(event != null){ Log.i("DB", "initMyEvent.size()==>" + event.size()); for(int i=0 ; i<event.size() ; i++) { events.add(ChangEventVo.event2Event(event.get(i))) ; //Log.i("DB", "=initMyEvent=>" + event.get(i).toString()); } } }catch(DbException e){ Log.e("DB", "error :" + e.getMessage() + "\n"); } return events; } @Override protected void onPostExecute(ArrayList<EventVo> result) { super.onPostExecute(result); ArrayListUtil.sortEventVo(result); refresh.refresh(result, 1); } }.execute(); }
Example #16
Source Project: ALLGO Author: HsingPeng File: PastEventLogicImpl.java License: Apache License 2.0 | 5 votes |
@Override public void initEvent() { new AsyncTask<Void, Void, ArrayList<EventVo>>() { @Override protected ArrayList<EventVo> doInBackground(Void... params) { SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE); int uid = sharedPref.getInt("uid", -1) ; ArrayList<EventVo> events =new ArrayList<EventVo>(); try{ DbUtils db = DbUtils.create(context,uid + ".db"); db.configAllowTransaction(true); db.configDebug(true); List<EventVo> event = db.findAll(Selector.from(PastEventVo.class)); if(event != null){ Log.i("DB", "initPastEvent.size()==>" + event.size()); for(int i=0 ; i<event.size() ; i++) { events.add(ChangEventVo.event2Event(event.get(i))) ; //Log.i("DB", "=initPastEvent=>" + event.get(i).toString()); } } }catch(DbException e){ Log.e("DB", "error :" + e.getMessage() + "\n"); } return events; } @Override protected void onPostExecute(ArrayList<EventVo> result) { super.onPostExecute(result); ArrayListUtil.sortEventVo(result); refresh.refresh(result, 1); } }.execute(); }
Example #17
Source Project: ALLGO Author: HsingPeng File: FriendsEventLogicImpl.java License: Apache License 2.0 | 5 votes |
/** * 从数据库初始化 */ @Override public void initEvent() { new AsyncTask<Void, Void, ArrayList<EventVo>>() { @Override protected ArrayList<EventVo> doInBackground(Void... params) { SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE); int uid = sharedPref.getInt("uid", -1) ; ArrayList<EventVo> events =new ArrayList<EventVo>(); try{ DbUtils db = DbUtils.create(context,uid + ".db"); db.configAllowTransaction(true); db.configDebug(true); List<EventVo> event = db.findAll(Selector.from(FriendEventVo.class)); if(event != null){ Log.i("DB", "initfriendsEvent.size()==>" + event.size()); for(int i=0 ; i<event.size() ; i++) { events.add(ChangEventVo.event2Event(event.get(i))) ; //Log.i("DB", "=initfriendsEvent=>" + event.get(i).toString()); } } }catch(DbException e){ Log.e("DB", "error :" + e.getMessage() + "\n"); } return events; } @Override protected void onPostExecute(ArrayList<EventVo> result) { super.onPostExecute(result); ArrayListUtil.sortEventVo(result); refresh.refresh(result, 1); } }.execute(); }
Example #18
Source Project: ALLGO Author: HsingPeng File: CommonEventLogicImpl.java License: Apache License 2.0 | 5 votes |
/** * 初始化所有活动列表,从数据库得到数据 * @param context */ @Override public void initEvent() { new AsyncTask<Void, Void, ArrayList<EventVo>>() { @Override protected ArrayList<EventVo> doInBackground(Void... params) { SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE); int uid = sharedPref.getInt("uid", -1) ; ArrayList<EventVo> events =new ArrayList<EventVo>(); try{ DbUtils db = DbUtils.create(context,uid + ".db"); db.configAllowTransaction(true); db.configDebug(true); List<EventVo> event = db.findAll(Selector.from(CommonEventVo.class)); if(event != null){ Log.i("DB", "initcommonEvent.size()==>" + event.size()); for(int i=0 ; i<event.size() ; i++) { events.add(ChangEventVo.event2Event(event.get(i))) ; } } }catch(DbException e){ Log.e("DB", "error :" + e.getMessage() + "\n"); } return events; } @Override protected void onPostExecute(ArrayList<EventVo> result) { super.onPostExecute(result); ArrayListUtil.sortEventVo(result); refresh.refresh(result, 1); } }.execute(); }
Example #19
Source Project: ALLGO Author: HsingPeng File: UnreadLogicImpl.java License: Apache License 2.0 | 5 votes |
/** * 开程序初始化 */ @Override public void initUnread() { new AsyncTask<Void, Void, ArrayList<UnreadVo>>() { @Override protected ArrayList<UnreadVo> doInBackground(Void... params) { SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE); int uid = sharedPref.getInt("uid", -1) ; ArrayList<UnreadVo> unreads =new ArrayList<UnreadVo>(); try{ DbUtils db = DbUtils.create(context,uid + ".db"); db.configAllowTransaction(true); db.configDebug(true); List<UnreadVo> unread = db.findAll(Selector.from(UnreadVo.class)); if(unread != null){ Log.i("DB", "initUnread.size()==>" + unread.size()); for(int i=0 ; i<unread.size() ; i++) { unreads.add(unread.get(i)) ; //Log.i("DB", "=initUnreadEvent=>" + unread.get(i).toString()); } } }catch(DbException e){ Log.e("DB", "error :" + e.getMessage() + "\n"); } return unreads; } @Override protected void onPostExecute(ArrayList<UnreadVo> result) { super.onPostExecute(result); ArrayListUtil.sortUnreadVo(result); refresh.refresh(result, 1); } }.execute(); }
Example #20
Source Project: android-open-project-demo Author: android-cn File: DbFragment.java License: Apache License 2.0 | 5 votes |
@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(); } }