Java Code Examples for com.lidroid.xutils.exception.DbException#printStackTrace()

The following examples show how to use com.lidroid.xutils.exception.DbException#printStackTrace() . 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
private void initDate() {
	siteTool = new GosScheduleSiteTool(this, device, spf.getString("Token", ""));
	DbUtils.DaoConfig config = new DaoConfig(this);
	config.setDbName("gizwits");
	config.setDbVersion(1); // db版本
	dbUtils = DbUtils.create(config);// db还有其他的一些构造方法,比如含有更新表版本的监听器的DbUtils
	try {
		// 创建一张表
		dbUtils.createTableIfNotExist(GosScheduleData.class);
	} catch (DbException e) {
		e.printStackTrace();
	}
	GosScheduleData.setSiteTool(siteTool);
	GosScheduleData.setDbUtils(dbUtils);
	GosScheduleData.setContext(getApplicationContext());
	setProgressDialog(getResources().getString(R.string.site_setting_time), true, false);
}
 
Example 2
Source Project: qingyang   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 3
Source Project: qingyang   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 4
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: Apache License 2.0 5 votes vote down vote up
public static void addAllEmoji(Context context, List<EmoticonBean> beans) {
    DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null);
    try {
        dbUtils.saveAll(beans);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: Apache License 2.0 5 votes vote down vote up
public static List<EmoticonBean> getAllEmojis(Context context) {
    DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null);
    try {
        return dbUtils.findAll(EmoticonBean.class);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 6
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: 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 7
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: 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;
}
 
Example 8
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: 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 9
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static List<EmoticonSetBean> getEmojiSets(Context context) {
    DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null);
    try {
        EmoticonSetBean setBean = dbUtils.findFirst(EmoticonSetBean.class);
        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 10
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: Apache License 2.0 5 votes vote down vote up
public static List<EmoticonSetBean> getAllEmojiSet(Context context) {
    DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null);
    try {
        List<EmoticonSetBean> setBean = dbUtils.findAll(EmoticonSetBean.class);
        return setBean;
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 11
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: 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 12
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: 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 13
Source Project: BigApp_Discuz_Android   File: EmojiDb.java    License: Apache License 2.0 5 votes vote down vote up
public static void clear(Context context) {
    DbUtils dbUtils = DbUtils.create(context, DB_NAME, DB_VERSION, null);
    try {
        dbUtils.dropTable(EmoticonSetBean.class);
        dbUtils.dropTable(EmoticonBean.class);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example 14
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 15
/**
 * Description:将云端信息写入到本地数据库
 * 
 * @param dataList
 */
@SuppressWarnings("unchecked")
protected void writeToLocalDatabase(List<ConcurrentHashMap<String, Object>> dataList) {

	String uid = spf.getString("Uid", "");

	for (ConcurrentHashMap<String, Object> map : dataList) {
		String date = (String) map.get("date");
		String time = (String) map.get("time");
		String repeat = (String) map.get("repeat");
		String ruleID = (String) map.get("ruleID");
		String did = (String) map.get("did");
		ConcurrentHashMap<String, Object> dataMap = (ConcurrentHashMap<String, Object>) map.get("dataMap");
		Boolean onOff = (Boolean) dataMap.get("Power_Switch");
		GosScheduleData newDate = new GosScheduleData();
		newDate.setUid(uid);
		newDate.setDid(did);
		newDate.setDate(date);
		newDate.setTime(time);
		newDate.setRepeat(repeat);
		setUserPickRepeat(time, repeat, newDate);
		newDate.setRuleID(ruleID);
		newDate.setOnOff(onOff);
		newDate.setDeleteOnsite(false);
		
		try {
			dbUtils.save(newDate);
		} catch (DbException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	
}
 
Example 16
/**
 * 下载文件
 */
public void downloadHttpRequest(){
    if(downloadInfo != null && downloadManager != null){
        try {
            downloadManager.addNewDownload(downloadInfo.getDownloadUrl(),
                    downloadInfo.getFileName(),
                    downloadInfo.getFileSavePath(),
                    downloadInfo.isAutoResume(), // 如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。
                    downloadInfo.isAutoRename(), // 如果从请求返回信息中获取到文件名,下载完成后自动重命名。
                    downloadCallback);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }
}
 
Example 17
/**
 * 下载文件
 */
public void downloadHttpRequest(){
    if(downloadInfo != null && downloadManager != null){
        try {
            downloadManager.addNewDownload(downloadInfo.getDownloadUrl(),
                    downloadInfo.getFileName(),
                    downloadInfo.getFileSavePath(),
                    downloadInfo.isAutoResume(), // 如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。
                    downloadInfo.isAutoRename(), // 如果从请求返回信息中获取到文件名,下载完成后自动重命名。
                    downloadCallback);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }
}
 
Example 18
Source Project: qingyang   File: DBManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 保存上传信息
 * 
 * @param upload
 * @return
 */
public boolean saveUpload(Upload upload) {
	try {
		db.save(upload);
	} catch (DbException e) {
		e.printStackTrace();
		return false;
	}
	return true;
}
 
Example 19
@OnClick(R.id.db_add)
public void add(View view) {
	try {
		Student student = new Student();
		student.setName("张三");
		student.setId(10086);
		student.setAge(18);
		student.setMan(true);
		student.setTime(new Date());
		student.setDate(new java.sql.Date(new Date().getTime()));
		db.save(student);

		student = new Student();
		student.setName("李四");
		student.setId(10010);
		student.setAge(15);
		student.setMan(true);
		student.setTime(new Date());
		student.setDate(new java.sql.Date(new Date().getTime()));
		db.save(student);

		student = new Student();
		student.setName("小红");
		student.setId(10000);
		student.setAge(15);
		student.setMan(false);
		student.setTime(new Date());
		student.setDate(new java.sql.Date(new Date().getTime()));
		db.save(student);
		Toast.makeText(this.getActivity(), "添加成功", Toast.LENGTH_SHORT).show();
	} catch (DbException e) {
		e.printStackTrace();
	}
}
 
Example 20
@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();
	}
}