ContentResolver insert - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ContentResolver insert method.

This code example shows how to use the following methods:insert
    } 
 
    public static Uri insert(Context context, ContentResolver resolver,
            Uri uri, ContentValues values) {
        try { 
            return resolver.insert(uri, values);
        } catch (SQLiteException e) {
            Log.e(TAG, "Catch a SQLiteException when insert: ", e);
            checkSQLiteException(context, e);
            return null; 
        } 
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, put
	 * Добавляет в галерею запись о добавленном файле(не надо сканировать всю память) 
	 * @param contect 
	 * @param file 
	 */ 
	private static void addImageGallery(Context contect, File file ) {
	    ContentValues values = new ContentValues();
	    values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
	    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); // setar isso
	    values.put(MediaStore.Images.Media.DESCRIPTION, MEDIA_TAG);
	    contect.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
	} 
	 
	/* 
	public static void appendLog(String text) 
	{        
	   File logFile = new File("sdcard/photo-of-the-day-log.txt"); 
	   if (!logFile.exists()) 
	   { 
	      try 
	      { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, put
    // Cameraボタンが押されたら呼び出されます。 
    public void onCameraButtonClick(View view) {
        // 標準のカメラアプリを呼び出します。 
        String filename =
                "Recipe_" + System.currentTimeMillis() + ".jpg";
        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.TITLE, filename);
        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
        mPictureUri = getContentResolver().insert(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
 
        Intent intent = new Intent();
        intent.setAction("android.media.action.IMAGE_CAPTURE");
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mPictureUri);
        startActivityForResult(intent, CODE_CAMERA);
    } 
 
    // Audioボタンが押されたら呼び出されます。 
    public void onAudioButtonClick(View view) {
        // ボイスレコーダーを呼び出します。 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:delete, insert, query
	 */ 
	public static long getPlaylist(ContentResolver resolver, String name)
	{ 
		long id = -1;
 
		Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
			new String[] { MediaStore.Audio.Playlists._ID },
			MediaStore.Audio.Playlists.NAME + "=?",
			new String[] { name }, null);
 
		if (cursor != null) {
			if (cursor.moveToNext())
				id = cursor.getLong(0);
			cursor.close();
		} 
 
		return id;
	} 
 
	/** 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, query, update
        value.put(Registry.AUTHORIZE_URL, "http://authorize");
        value.put(Registry.CONSUMER_KEY, "key");
        value.put(Registry.CONSUMER_SECRET, "secret123");
        value.put(Registry.URL, "http://twitter.com");
 
        Uri uri = mResolver.insert(REGISTRY_URI, value);
        assertNotNull(uri);
 
        value.clear();
        value.put(Registry.ACCESS_SECRET, "mysec");
        value.put(Registry.ACCESS_TOKEN, "mytok");
        assertEquals(1, mResolver.update(uri, value, null, null));
 
        Cursor cur = mResolver.query(uri, new String[] {
                Registry.ACCESS_SECRET, Registry.ACCESS_TOKEN 
        }, null, null, null); 
         
        assertTrue(cur.moveToFirst());
        assertEquals("mysec", cur.getString(cur.getColumnIndexOrThrow(Registry.ACCESS_SECRET)));
        assertEquals("mytok", cur.getString(cur.getColumnIndexOrThrow(Registry.ACCESS_TOKEN)));
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, openAssetFileDescriptor, query, update
	public void updatePhoto(ContentResolver cr, byte[] photo, String id, boolean markDirty, boolean fromthumb) { 
		if (cr == null || id == null) {
			return; 
		} 
		 
		long rawId = queryForRawContactId(cr, Long.parseLong(id));
		if (rawId < 0) {
			return; 
		} 
		//if(!fromthumb) 
			writeDisplayPhoto(cr, rawId, photo);
		 
		if(photo == null)
		{ 
			id = String.valueOf(rawId);
			ContentValues values = new ContentValues(); 
			int photoRow = -1; 
			 
			// query for existing photo 
			String where = ContactsContract.Data.RAW_CONTACT_ID + " == " + 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, put
    /** Start the an external camera intent */ 
    public void startCameraIntent() { 
 
        String imageFileName = UUID.randomUUID().toString() + ".jpg";
 
        ContentValues contentValues = new ContentValues();
        contentValues.put(MediaStore.Images.Media.TITLE, imageFileName);
 
        mImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
 
        Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT, mImageURI);
 
        try { 
            startActivityForResult(i, IMAGE_CAPTURE_REQUEST);
        } 
        catch (ActivityNotFoundException e) {
            Log.e(TAG, "Could not start a Camera Intent");
        } 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert
    } 
 
    public static Uri insert(Context context, ContentResolver resolver,
            Uri uri, ContentValues values) {
        try { 
            return resolver.insert(uri, values);
        } catch (SQLiteException e) {
            Log.e(TAG, "Catch a SQLiteException when insert: ", e);
            checkSQLiteException(context, e);
            return null; 
        } 
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, containsKey, getAsLong, getAsString, put
	} 
	 
	public void persist(Context ctx){
		prepare(); 
		Log.v(getClass().getName(), "Persisting...");
		ctx.getContentResolver().insert(Uri.withAppendedPath(contentProviderUri, entityName), contentValues);
	} 
	 
	public void prepare(){ 
		/*for(Map.Entry<String,String> entry : nonPersistableFieldsMap.entrySet()){ 
			if(stringFields.contains(entry.getValue())){ 
				contentValues.put(entry.getValue(), contentValues.getAsString(entry.getKey())); 
				contentValues.remove(entry.getKey()); 
			}else if(intFields.contains(entry.getValue())){ 
				contentValues.put(entry.getValue(), contentValues.getAsInteger(entry.getKey())); 
				contentValues.remove(entry.getKey()); 
			} 
		}*/ 
		 
		if(getId()==0)contentValues.put("_id", UUID.randomUUID().getMostSignificantBits());

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, put
 
    // Recipe088 
    public void onLargeCameraButton(View view) {
        String filename = "Recipe_" + System.currentTimeMillis() + ".jpg";
 
        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.TITLE, filename);
        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
        mPictureUri = getContentResolver().insert(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
 
        Intent intent = new Intent();
        // intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); 
        intent.setAction("android.media.action.IMAGE_CAPTURE");
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mPictureUri);
        startActivityForResult(intent, REQUEST_CODE_2);
    } 
 
    // Recipe089 
    public void onVideoButton(View view) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related ContentResolver insert Questions & Answers:

Other ContentResolver insert Examples

71:	
72:	    Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
73:	    Uri newUri = contentResolver.insert(base, values);
74:	
75:	    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, newUri));

Read More

insert Method Overview
Inserts a row into a table at the given URL.
See Code Examples for other Android ContentResolver Methods: