/** * 保存好友列表. 请在后台操作。 * * @param customerVos * @return 作者:fighter <br> * 创建时间:2013-5-31<br> * 修改时间:<br> */ public boolean saveFriendList(List<CustomerVo> customerVos) { Log.d(TAG, "saveFriendList()"); try { friendListVo = new FriendListVo(); friendListVo.setUid(userInfoVo.getUid()); friendListVo.setUpdateTime(System.currentTimeMillis() + ""); StringBuffer buffer = new StringBuffer(); int index = customerVos.size(); for (int i = 0; i < index; i++) { CustomerVo customerVo = customerVos.get(i); customerVo.setFriend("1"); buffer.append("'").append(customerVo.getUid()).append("'"); if (i == (index - 1)) { continue; } buffer.append(","); } String friends = buffer.toString(); friendListVo.setFriends(friends); finalDb.delete(friendListVo); finalDb.save(friendListVo); finalDb.deleteByWhere(CustomerVo.class, "uid in (" + friends + ")"); finalDb.saveList(customerVos); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
/** * 新建图片的缩略图 并存数据库 * * @param sourcePath * @return */ private String createImgBitmapThum(String sourcePath) { if (!isFileExist(sourcePath)) { System.out.println(sourcePath + "-----------not exsit"); return null; } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile(sourcePath, options); // System.out.println("bitmap -- " + bitmap); options.inJustDecodeBounds = false; int be = (int) (options.outHeight / (float) 200); // 原图 压缩成 128*128的缩略图 if (be <= 0) { be = 1; } options.inSampleSize = be; bitmap = BitmapFactory.decodeFile(sourcePath, options); // int w = bitmap.getWidth(); // int h = bitmap.getHeight(); // System.out.println(w + " " + h); String path = getSDPath(); System.out.println("path --------- " + path); if (path == null) { app().showMsg("没有找到sd卡"); return null; } String photoName = System.currentTimeMillis() + ""; ImageTools.savePhotoToSDCard(bitmap, path, photoName); MyAlbumThumBean bean = new MyAlbumThumBean(); bean.setSourthPath(sourcePath); bean.setPhotoName(photoName); bean.setThumPath(path); db.save(bean); return path + "/" + photoName + ".png"; }
/** * 保存数据 * * @param model */ public void SaveModel(Object model) { db.save(model); }