private void updateShareTVdatabase(Movie movie, int postion) { // TODO Auto-generated method stub Cursor mCursor = null; SQLiteDatabase db = null; try { Log.d("renjun1", "111111111"); // SQLiteDatabase db = dbHelper.getWritableDatabase(); db = dbHelper.getWritableDatabase(); mCursor = db.query( FlyShareTVdataHelper.TBL_HISTORY_VIDEOS, new String[] {"_id,_uri"}, "_id=?", new String[] {movie.getData().getMovieId()}, null, null, null); ContentValues values = new ContentValues(); String nowTime = getCurrentTime(); String filename = movie.getData().getMovieName(); String thumb = movie.getData().getThumb(); Log.d("renjun1", "filename:" + filename); Log.d("renjun1", "videoUri " + videoUri); Log.d("renjun1", "nowTime " + nowTime); Log.d("renjun1", "postion:" + postion); values.put("_uri", movie.getData().getFilmUrl()); values.put("_id", movie.getData().getMovieId()); values.put("_time", nowTime); values.put("_pos", postion); values.put("_name", filename); values.put("_thumb", thumb); if (mCursor == null || mCursor.getCount() == 0) { Log.d("renjun1", "22222222"); dbHelper.insert(values); } else { Log.d("renjun1", "3333333333"); dbHelper.update(values, movie.getData().getMovieId()); } } finally { if (mCursor != null) { mCursor.close(); } if (db != null) { db.close(); } } }
private void updateFavState(String uri, boolean isSelected) { // TODO Auto-generated method stub Cursor mCursor = null; SQLiteDatabase db = null; try { Log.d("renjun1", "111111111"); db = dbHelper.getWritableDatabase(); mCursor = db.query( "play_history", new String[] {"_id,_uri"}, "_uri=?", new String[] {videoUri}, null, null, null); ContentValues values = new ContentValues(); Log.d("renjun1", "uri " + uri); values.put("_uri", videoUri); values.put("_fav", isSelected ? 1 : 0); if (mCursor == null || mCursor.getCount() == 0) { Log.d("renjun1", "22222222"); dbHelper.insert(values); } else { Log.d("renjun1", "3333333333"); dbHelper.update(values, uri); } } finally { if (mCursor != null) { mCursor.close(); } if (db != null) { db.close(); } } }