当前位置: 首页>>代码示例>>Java>>正文


Java DBHelper类代码示例

本文整理汇总了Java中cn.eoe.app.db.DBHelper的典型用法代码示例。如果您正苦于以下问题:Java DBHelper类的具体用法?Java DBHelper怎么用?Java DBHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DBHelper类属于cn.eoe.app.db包,在下文中一共展示了DBHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setThumbnailView

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
/**
 * 入口
 * 
 * @param imageUrl
 * @param iv_item_image
 * @param context
 * @param callback
 * @param b
 */
public static void setThumbnailView(String imageUrl,
		ImageView iv_item_image, Context context, ImageCallback callback,
		boolean b) {
	DBHelper dbHelper = DBHelper.getInstance(context);
	String md5 = ImageUtil.md5(imageUrl);
	
	
	// 缓存目录

	if (!CommonUtil.sdCardIsAvailable())/* true 为可用 */{
		String cachePath = context.getCacheDir().getAbsolutePath() + "/" + md5; // data里的缓存
		setThumbnailImage(iv_item_image, imageUrl, cachePath, dbHelper,
				callback, b);
		iv_item_image.setTag(cachePath);
	} else {
		String imagePath = getExternalCacheDir(context) + File.separator + md5; // sd卡
		setThumbnailImage(iv_item_image, imageUrl, imagePath, dbHelper,
				callback, b);
		iv_item_image.setTag(imagePath);
	}
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:31,代码来源:ImageUtil.java

示例2: getImageFromDB

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
private static Bitmap getImageFromDB(String imagePath, String imageUrl,
		DBHelper dbHelper) {
	Cursor cursor = queryFromDbByImgUrl(dbHelper, imageUrl);
	if (cursor.moveToFirst()) {
		long currTimestamp = (new Date()).getTime();
		long timestamp = cursor.getLong(cursor
				.getColumnIndex(ImageCacheColumn.TIMESTAMP));
		long spanTime = currTimestamp - timestamp;
		int Past_time = cursor.getInt(cursor
				.getColumnIndex(ImageCacheColumn.PAST_TIME));
		if (spanTime > Past_time * 24 * 60 * 60 * 1000) {
			// 过期
			// 删除本地文件
			deleteImageFromLocal(imagePath);
			return null;
		} else {
			// 没过期
			return getImageFromLocal(imagePath);
		}
	} else {
		return null;
	}
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:24,代码来源:ImageUtil.java

示例3: saveImageByDb

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
private static void saveImageByDb(String imageUrl, DBHelper dbHelper) {
	String sql = null;
	if (queryFromDbByImgUrl(dbHelper, imageUrl).moveToFirst()) {
		sql = "update " + ImageCacheColumn.TABLE_NAME + " set "
				+ ImageCacheColumn.TIMESTAMP + "='"
				+ (new Date().getTime()) + "' where "
				+ ImageCacheColumn.Url + "='" + imageUrl + "'";
	} else {
		sql = "insert into " + ImageCacheColumn.TABLE_NAME + "("
				+ ImageCacheColumn.Url + "," + ImageCacheColumn.TIMESTAMP
				+ "," + ImageCacheColumn.PAST_TIME + ") values('"
				+ imageUrl + "'," + (new Date().getTime()) + "," + DayCount
				+ ")";
	}
	dbHelper.ExecSQL(sql);
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:17,代码来源:ImageUtil.java

示例4: getCacheRequest

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
private static String getCacheRequest(Context context, String requestUrl,
		String requestPath, String source_type, String content_type,
		DBHelper dbHelper, boolean useCache) {
	// TODO Auto-generated method stub
	String result = "";
	if (useCache) {
		result = getStringFromSoftReference(requestUrl);
		if (!result.equals(null) && !result.equals("")) {
			return result;
		}
		result = getStringFromLocal(requestPath, requestUrl, dbHelper);
		if (!result.equals(null) && !result.equals("")) {
			putStringForSoftReference(requestUrl, result);
			return result;
		}
	}
	result = getStringFromWeb(context, requestPath, requestUrl,
			source_type, content_type, dbHelper);
	return result;
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:21,代码来源:RequestCacheUtil.java

示例5: getStringFromWeb

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
private static String getStringFromWeb(Context context, String requestPath,
		String requestUrl, String source_type, String content_type,
		DBHelper dbHelper) {
	// TODO Auto-generated method stub
	String result = "";
	try {
		result = HttpUtils.getByHttpClient(context, requestUrl);
		if (result.equals(null) && result.equals("")) {
			return result;
		}
		// 更新数据库
		Cursor cursor = getStringFromDB(requestUrl, dbHelper);
		updateDB(cursor, requestUrl, source_type, content_type, dbHelper);
		saveFileByRequestPath(requestPath, result);
		putStringForSoftReference(requestUrl, result);
	} catch (Exception e) {
		e.printStackTrace();
	}
	return result;
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:21,代码来源:RequestCacheUtil.java

示例6: getStringFromLocal

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
private static String getStringFromLocal(String requestPath,
		String requestUrl, DBHelper dbHelper) {
	String result = "";
	Cursor cursor = getStringFromDB(requestUrl, dbHelper);
	if (cursor.moveToFirst()) {
		Long timestamp = cursor.getLong(cursor
				.getColumnIndex(RequestCacheColumn.Timestamp));
		String strContentType = cursor.getString(cursor
				.getColumnIndex(RequestCacheColumn.Content_type));
		long span = getSpanTimeFromConfigs(strContentType);
		long nowTime = System.currentTimeMillis();
		if ((nowTime - timestamp) > span * 60 * 1000) {
			// 过期
			deleteFileFromLocal(requestPath);
		} else {
			// 没过期
			result = getFileFromLocal(requestPath);
		}
	}
	return result;
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:22,代码来源:RequestCacheUtil.java

示例7: setThumbnailView

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
/**
 * 入口
 * 
 * @param imageUrl
 * @param iv_item_image
 * @param context
 * @param callback
 * @param b
 */
public static void setThumbnailView(String imageUrl,
		ImageView iv_item_image, Context context, ImageCallback callback,
		boolean b) {
	DBHelper dbHelper = DBHelper.getInstance(context);
	String md5 = ImageUtil.md5(imageUrl);
	String cachePath = context.getCacheDir().getAbsolutePath() + "/" + md5; // data里的缓存
	String imagePath = getExternalCacheDir(context) + File.separator + md5; // sd卡
	// 缓存目录

	if (!CommonUtil.sdCardIsAvailable())/* true 为可用 */{
		setThumbnailImage(iv_item_image, imageUrl, cachePath, dbHelper,
				callback, b);
		iv_item_image.setTag(cachePath);
	} else {
		setThumbnailImage(iv_item_image, imageUrl, imagePath, dbHelper,
				callback, b);
		iv_item_image.setTag(imagePath);
	}
}
 
开发者ID:RyanLee7,项目名称:eoe_android,代码行数:29,代码来源:ImageUtil.java

示例8: setThumbnailImage

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
/**
 * 设置图片函数
 * 
 * @param view
 * @param imageUrl
 * @param cachePath
 * @param callback
 * @param b
 */
private static void setThumbnailImage(ImageView view, String imageUrl,
		String cachePath, DBHelper dbHelper, ImageCallback callback,
		boolean b) {
	Bitmap bitmap = null;
	bitmap = ImageUtil.loadThumbnailImage(cachePath, imageUrl, dbHelper,
			callback, b);
	if (bitmap == null) {// 先查找数据库,再查找本地sd卡,若没有.再从网站加载,若网站上没有图片或错误时返回null
		// 设置默认图片
		view.setImageResource(Default_Img);
	} else {
		// 设置本地SD卡缓存图片
		view.setImageBitmap(bitmap);
	}
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:24,代码来源:ImageUtil.java

示例9: queryFromDbByImgUrl

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
private static Cursor queryFromDbByImgUrl(DBHelper dbHelper, String imageUrl) {
	// return dbHelper.query(ImageCacheColumn.TABLE_NAME, null,
	// ImageCacheColumn.Url + "=?", new String[] { imageUrl });
	return dbHelper.rawQuery("select * from " + ImageCacheColumn.TABLE_NAME
			+ "  where " + ImageCacheColumn.Url + "='" + imageUrl + "'",
			null);
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:8,代码来源:ImageUtil.java

示例10: getRequestContent

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
public static String getRequestContent(Context context, String RequestUrl,
		String source_type, String content_type, boolean UseCache) {
	DBHelper dbHelper = DBHelper.getInstance(context);
	String md5 = MD5.encode(RequestUrl);
																					// 缓存目录
	if (!CommonUtil.sdCardIsAvailable())/* true 为可用 */{
		String cachePath = context.getCacheDir().getAbsolutePath() + "/" + md5; // data里的缓存
		return getCacheRequest(context, RequestUrl, cachePath, source_type,
				content_type, dbHelper, UseCache);
	} else {
		String imagePath = getExternalCacheDir(context) + File.separator + md5; // sd卡
		return getCacheRequest(context, RequestUrl, imagePath, source_type,
				content_type, dbHelper, UseCache);
	}
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:16,代码来源:RequestCacheUtil.java

示例11: onDestroy

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
@Override
protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    try {
        DBHelper db = DBHelper.getInstance(this);
        db.closeDb();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:12,代码来源:MainActivity.java

示例12: getRequestContent

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
public static String getRequestContent(Context context, String RequestUrl,
		String source_type, String content_type, boolean UseCache) {
	DBHelper dbHelper = DBHelper.getInstance(context);
	String md5 = MD5.encode(RequestUrl);
	String cachePath = context.getCacheDir().getAbsolutePath() + "/" + md5; // data里的缓存
	String imagePath = getExternalCacheDir(context) + File.separator + md5; // sd卡
																			// 缓存目录
	if (!CommonUtil.sdCardIsAvailable())/* true 为可用 */{
		return getCacheRequest(context, RequestUrl, cachePath, source_type,
				content_type, dbHelper, UseCache);
	} else {
		return getCacheRequest(context, RequestUrl, imagePath, source_type,
				content_type, dbHelper, UseCache);
	}
}
 
开发者ID:RyanLee7,项目名称:eoe_android,代码行数:16,代码来源:RequestCacheUtil.java

示例13: onDestroy

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
@Override
protected void onDestroy() {
	// TODO Auto-generated method stub
	super.onDestroy();
	try {
		DBHelper db = DBHelper.getInstance(this);
		db.closeDb();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:RyanLee7,项目名称:eoe_android,代码行数:12,代码来源:MainActivity.java

示例14: DetailDB

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
public DetailDB(Context context) {
	dbHelper = DBHelper.getInstance(context);
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:4,代码来源:DetailDB.java

示例15: getStringFromDB

import cn.eoe.app.db.DBHelper; //导入依赖的package包/类
/**
 * 从db中查找数据
 * 
 * @param requestUrl
 * @param dbHelper
 * @return
 */
private static Cursor getStringFromDB(String requestUrl, DBHelper dbHelper) {
	String SQL = "select * from " + RequestCacheColumn.TABLE_NAME
			+ " where " + RequestCacheColumn.URL + "='" + requestUrl + "'";
	Cursor cursor = dbHelper.rawQuery(SQL, new String[] {});
	return cursor;
}
 
开发者ID:shengge,项目名称:eoe-android-app,代码行数:14,代码来源:RequestCacheUtil.java


注:本文中的cn.eoe.app.db.DBHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。