Android JSON Insert insertJSONObjectContent( ContentResolver contentResolver, Uri uri, JSONObject obj)

Here you can find the source of insertJSONObjectContent( ContentResolver contentResolver, Uri uri, JSONObject obj)

Description

insert JSON Object Content

Declaration

public static void insertJSONObjectContent(
            ContentResolver contentResolver, Uri uri, JSONObject obj)
            throws JSONException 

Method Source Code

//package com.java2s;

import java.util.Iterator;

import org.json.JSONException;
import org.json.JSONObject;
import android.content.ContentResolver;
import android.content.ContentValues;

import android.net.Uri;

public class Main {
    public static void insertJSONObjectContent(
            ContentResolver contentResolver, Uri uri, JSONObject obj)
            throws JSONException {
        ContentValues values = new ContentValues();
        Iterator<String> it = (Iterator<String>) obj.keys();
        while (it.hasNext()) {
            String key = it.next();
            values.put(key, obj.getString(key));
        }// w w w  .j  a v a  2s.com
        contentResolver.insert(uri, values);
    }
}

Related

  1. insertJSONArrayContent( ContentResolver contentResolver, Uri uri, JSONArray array)
  2. concatArray(JSONArray arr1, JSONArray arr2)