List of usage examples for android.content ContentValues put
public void put(String key, byte[] value)
From source file:com.seneca.android.senfitbeta.DbHelper.java
public void insertExercise(String aut, String des, String name, String ogName, String date, String cat, int id) { Log.d("INSERT EXDB", "Inserting exercise..."); SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(AUTHOR, aut); values.put(DESCRIPTION, des);//from ww w . j a v a 2s . c o m values.put(NAMETYPE, name); values.put(ORIGNALNAME, ogName); values.put(CREATIONDATE, date); values.put(CATEGORY, cat); values.put(EXERCISE_ID, id); long info = db.insert(EXERCISE_TABLE, null, values); }
From source file:es.uma.lcc.tasks.EncryptionUploaderTask.java
private void addToGallery(String path) { ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.DATA, path); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); mMainActivity.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); }
From source file:net.bible.service.db.bookmark.BookmarkDBAdapter.java
public void insertBookmarkLabelJoin(BookmarkDto bookmark, LabelDto label) { // Create a new row of values to insert. ContentValues newValues = new ContentValues(); newValues.put(BookmarkLabelColumn.BOOKMARK_ID, bookmark.getId()); newValues.put(BookmarkLabelColumn.LABEL_ID, label.getId()); //long newId = db.insert(Table.BOOKMARK_LABEL, null, newValues); }
From source file:net.olejon.mdapp.ClinicalTrialsCardsActivity.java
private void search(final String string, boolean cache) { try {//from w w w . j ava2 s. c om RequestQueue requestQueue = Volley.newRequestQueue(mContext); String apiUri = getString(R.string.project_website_uri) + "api/1/clinicaltrials/?search=" + URLEncoder.encode(string.toLowerCase(), "utf-8"); if (!cache) requestQueue.getCache().remove(apiUri); JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(apiUri, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { mProgressBar.setVisibility(View.GONE); mSwipeRefreshLayout.setRefreshing(false); if (response.length() == 0) { mSwipeRefreshLayout.setVisibility(View.GONE); mNoClinicalTrialsLayout.setVisibility(View.VISIBLE); } else { if (mTools.isTablet()) { int spanCount = (response.length() == 1) ? 1 : 2; mRecyclerView.setLayoutManager( new StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL)); } mRecyclerView.setAdapter(new ClinicalTrialsCardsAdapter(mContext, response)); ContentValues contentValues = new ContentValues(); contentValues.put(ClinicalTrialsSQLiteHelper.COLUMN_STRING, string); SQLiteDatabase sqLiteDatabase = new ClinicalTrialsSQLiteHelper(mContext) .getWritableDatabase(); sqLiteDatabase.delete(ClinicalTrialsSQLiteHelper.TABLE, ClinicalTrialsSQLiteHelper.COLUMN_STRING + " = " + mTools.sqe(string) + " COLLATE NOCASE", null); sqLiteDatabase.insert(ClinicalTrialsSQLiteHelper.TABLE, null, contentValues); sqLiteDatabase.close(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { mProgressBar.setVisibility(View.GONE); mSwipeRefreshLayout.setRefreshing(false); mTools.showToast(getString(R.string.clinicaltrials_cards_something_went_wrong), 1); finish(); Log.e("ClinicalTrialsCards", error.toString()); } }); jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(30000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(jsonArrayRequest); } catch (Exception e) { Log.e("ClinicalTrialsCards", Log.getStackTraceString(e)); } }
From source file:com.moez.QKSMS.mmssms.Transaction.java
private static Uri createPartImage(Context context, String id, byte[] imageBytes, String mimeType) throws Exception { ContentValues mmsPartValue = new ContentValues(); mmsPartValue.put("mid", id); mmsPartValue.put("ct", mimeType); mmsPartValue.put("cid", "<" + System.currentTimeMillis() + ">"); Uri partUri = Uri.parse("content://mms/" + id + "/part"); Uri res = context.getContentResolver().insert(partUri, mmsPartValue); // Add data to part OutputStream os = context.getContentResolver().openOutputStream(res); ByteArrayInputStream is = new ByteArrayInputStream(imageBytes); byte[] buffer = new byte[256]; for (int len = 0; (len = is.read(buffer)) != -1;) { os.write(buffer, 0, len);/* w w w . java 2 s . co m*/ } os.close(); is.close(); return res; }
From source file:com.example.bdcoe.sunshine.FetchWeatherTask.java
private long addLocation(String locationSetting, String cityName, double lat, double lon) { Log.v(LOG_TAG, "inserting " + cityName + ", with coord: " + lat + ", " + lon); // First, check if the location with this city name exists in the db Cursor cursor = mContext.getContentResolver().query(WeatherContract.LocationEntry.CONTENT_URI, new String[] { WeatherContract.LocationEntry._ID }, WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING + " = ?", new String[] { locationSetting }, null);// w w w.ja va 2s. c om if (cursor.moveToFirst()) { Log.v(LOG_TAG, "Found it in the database!"); int locationIdIndex = cursor.getColumnIndex(WeatherContract.LocationEntry._ID); return cursor.getLong(locationIdIndex); } else { Log.v(LOG_TAG, "Didn't find it in the database, inserting now!"); ContentValues locationValues = new ContentValues(); locationValues.put(WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING, locationSetting); locationValues.put(WeatherContract.LocationEntry.COLUMN_CITY_NAME, cityName); locationValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LAT, lat); locationValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LONG, lon); Uri locationInsertUri = mContext.getContentResolver().insert(WeatherContract.LocationEntry.CONTENT_URI, locationValues); return ContentUris.parseId(locationInsertUri); } }
From source file:com.example.premiereappandroid.BloaActivity.java
private ContentValues parseVerifyUserJSONObject(JSONObject object) throws Exception { ContentValues values = new ContentValues(); values.put(UserStatusRecord.USER_NAME, object.getString("name")); values.put(UserStatusRecord.RECORD_ID, object.getInt("id_str")); values.put(UserStatusRecord.USER_CREATED_DATE, object.getString("created_at")); JSONObject status = object.getJSONObject("status"); values.put(UserStatusRecord.USER_TEXT, status.getString("text")); return values; }
From source file:com.android.mail.browse.AttachmentActionHandler.java
private void startDownloadingAttachment(Attachment attachment, int destination, int rendition, int additionalPriority, boolean delayDownload) { //do not auto install apk from stream . must save first so that can be install if (attachment.state == AttachmentState.SAVED && destination == AttachmentDestination.EXTERNAL && !MimeType.isInstallable(attachment.getContentType())) { File savedFile = performAttachmentSave(attachment); if (savedFile != null && mView != null) { // The attachment is saved successfully from cache. mView.viewAttachment();/* w w w. ja v a2 s . c o m*/ return; } } final ContentValues params = new ContentValues(5); params.put(AttachmentColumns.STATE, AttachmentState.DOWNLOADING); params.put(AttachmentColumns.DESTINATION, destination); params.put(AttachmentContentValueKeys.RENDITION, rendition); params.put(AttachmentContentValueKeys.ADDITIONAL_PRIORITY, additionalPriority); params.put(AttachmentContentValueKeys.DELAY_DOWNLOAD, delayDownload); mCommandHandler.sendCommand(attachment.uri, params); }