com.lidroid.xutils.db.sqlite.Selector Java Examples

The following examples show how to use com.lidroid.xutils.db.sqlite.Selector. 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 File: DBManager.java    From qingyang with 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 #2
Source File: DBManager.java    From qingyang with 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 #3
Source File: DownloadManager.java    From AndroidAppCodeFramework with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: DbFragment.java    From android-open-project-demo with 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();
	}
}
 
Example #5
Source File: UnreadLogicImpl.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
/**
 * 开程序初始化
 */
@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 #6
Source File: CommonEventLogicImpl.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化所有活动列表,从数据库得到数据
 * @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 #7
Source File: FriendsEventLogicImpl.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
/**
 * 从数据库初始化
 */
@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 #8
Source File: PastEventLogicImpl.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: MyEventLogicImpl.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@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 #10
Source File: DownloadManager.java    From AndroidAppCodeFramework with Apache License 2.0 5 votes vote down vote up
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 #11
Source File: EmojiDb.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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 #12
Source File: GosScheduleListActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
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 File: CollectDAO.java    From QiQuYing with 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 #14
Source File: CollectDAO.java    From QiQuYing with 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 #15
Source File: DingCaiDAO.java    From QiQuYing with 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 #16
Source File: DingCaiDAO.java    From QiQuYing with 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 #17
Source File: EmojiDb.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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 #18
Source File: EmojiDb.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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 #19
Source File: EmojiDb.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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 #20
Source File: EmojiDb.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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;
}