Example usage for android.content ContentValues ContentValues

List of usage examples for android.content ContentValues ContentValues

Introduction

In this page you can find the example usage for android.content ContentValues ContentValues.

Prototype

public ContentValues() 

Source Link

Document

Creates an empty set of values using the default initial size

Usage

From source file:android.syncml.pim.PropertyNode.java

public PropertyNode() {
    propName = "";
    propValue = "";
    propValue_vector = new ArrayList<String>();
    paramMap = new ContentValues();
    paramMap_TYPE = new HashSet<String>();
    propGroupSet = new HashSet<String>();
}

From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java

public static void insertSubscriber(final Context c, Long contactId, String feedName) {
    ContentValues values = new ContentValues();
    values.put(Subscriber.CONTACT_ID, contactId);
    values.put("feed_name", feedName);
    Uri url = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/subscribers");
    c.getContentResolver().insert(url, values);
}

From source file:jen.jobs.application.DownloadDataTask.java

public void downloadProfile(final View v) {
    String[] profileUrl = { Jenjobs.PROFILE_URL + "?access-token=" + accessToken };
    GetRequest g = new GetRequest();
    g.execute(profileUrl);//  www  .  j ava2 s  . c  o m
    g.setResultListener(new GetRequest.ResultListener() {
        @Override
        public void processResultArray(JSONArray result) {
        }

        @Override
        public void processResult(JSONObject success) {
            if (success != null) {
                int js_profile_id;
                TableAddress tblAddress = new TableAddress(context);
                ContentValues cv = new ContentValues();

                try {
                    success.remove("_link"); // remove _link

                    cv.put("access_token", String.valueOf(accessToken));
                    cv.put("_id", String.valueOf(success.get("id")));
                    cv.put("email", String.valueOf(success.get("email")));
                    cv.put("username", String.valueOf(success.get("username")));
                    cv.put("name", String.valueOf(success.get("name")));
                    cv.put("ic_no", String.valueOf(success.get("ic_no")));
                    cv.put("passport_no", String.valueOf(success.get("passport_no")));
                    cv.put("mobile_no", String.valueOf(success.get("mobile_no")));
                    cv.put("dial_code", String.valueOf(success.get("dial_code")));
                    cv.put("gender", String.valueOf(success.get("gender")));
                    cv.put("dob", String.valueOf(success.get("dob")));
                    cv.put("pr", String.valueOf(success.get("pr")));
                    cv.put("resume_file", String.valueOf(success.get("resume_file")));
                    cv.put("photo_file", String.valueOf(success.get("photo_file")));
                    cv.put("access", String.valueOf(success.get("access")));
                    cv.put("status", String.valueOf(success.get("status")));
                    cv.put("country_id", String.valueOf(success.get("country_id")));
                    cv.put("driving_license", String.valueOf(success.get("driving_license")));
                    cv.put("transport", String.valueOf(success.get("transport")));
                    cv.put("js_jobseek_status_id", String.valueOf(success.get("js_jobseek_status_id")));
                    cv.put("availability", String.valueOf(success.get("availability")));
                    cv.put("availability_unit", String.valueOf(success.get("availability_unit")));
                    //cv.put("address", String.valueOf(success.get("address")));
                    cv.put("no_work_exp", String.valueOf(success.get("no_work_exp")));
                    cv.put("additional_info", String.valueOf(success.get("info")));
                    cv.put("created_at", String.valueOf(success.get("created_at")));
                    cv.put("updated_at", String.valueOf(success.get("updated_at")));

                    tableProfile.addProfile(cv);
                    js_profile_id = cv.getAsInteger("_id");
                    //Log.e("js_profile_id", String.valueOf(js_profile_id));

                    SharedPreferences.Editor spEdit = sharedPref.edit();
                    spEdit.putInt("js_profile_id", js_profile_id);
                    spEdit.apply();

                    // default address
                    ContentValues cv2 = new ContentValues();
                    cv2.put("address1", "");
                    cv2.put("address2", "");
                    cv2.put("postcode", 0);
                    cv2.put("city_id", 0);
                    cv2.put("city_name", "");
                    cv2.put("state_id", 0);
                    cv2.put("state_name", "");
                    cv2.put("country_id", 0);
                    cv2.put("updated_at", Jenjobs.date(null, null, null));
                    tblAddress.addAddress(cv2);

                    if (v != null) {
                        TextView name = (TextView) v.findViewById(R.id.fullName);
                        TextView email = (TextView) v.findViewById(R.id.email);
                        TextView mobile_no = (TextView) v.findViewById(R.id.mobile_no);
                        TextView ic_no = (TextView) v.findViewById(R.id.ic_no);
                        TextView gender = (TextView) v.findViewById(R.id.gender);
                        TextView dob = (TextView) v.findViewById(R.id.dob);
                        TextView country = (TextView) v.findViewById(R.id.country);
                        ImageView profileImage = (ImageView) v.findViewById(R.id.profile_image);

                        name.setText(String.valueOf(success.get("name")));
                        email.setText(String.valueOf(success.get("email")));
                        mobile_no.setText(String.valueOf(success.get("mobile_no")));
                        ic_no.setText(String.valueOf(success.get("ic_no")));
                        gender.setText(String.valueOf(success.get("gender")));
                        country.setText(String.valueOf(success.get("country")));

                        String _dob = String.valueOf(success.get("dob"));
                        if (_dob != null) {
                            dob.setText(Jenjobs.date(_dob, null, "yyyy-MM-dd"));
                        }

                        if (String.valueOf(success.get("photo_file")) != null) {
                            new ImageLoad(String.valueOf(success.get("photo_file")), profileImage).execute();
                        }
                    }

                    // save address
                    String address = String.valueOf(success.get("address"));
                    if (address != null && !address.equals("null")) {
                        JSONObject jsonAddr = new JSONObject(address);
                        ContentValues cv3 = new ContentValues();
                        cv3.put("address1", jsonAddr.getString("address1"));
                        cv3.put("address2", jsonAddr.getString("address2"));
                        String postCodeStr = jsonAddr.getString("postcode");
                        int postCode = 0;
                        if (postCodeStr != null && !postCodeStr.equals("null")) {
                            postCode = Integer.valueOf(postCodeStr);
                        }
                        cv3.put("postcode", postCode);
                        cv3.put("city_id", jsonAddr.getInt("city_id"));
                        cv3.put("city_name", jsonAddr.getString("city_name"));
                        cv3.put("state_id", jsonAddr.getInt("state_id"));
                        cv3.put("state_name", jsonAddr.getString("state_name"));
                        cv3.put("country_id", jsonAddr.getInt("country_id"));
                        cv3.put("updated_at", jsonAddr.getString("date_updated"));
                        tblAddress.updateAddress(cv3);
                    }
                    // end save address
                } catch (JSONException e) {
                    Log.e("profileExcp", e.getMessage());
                }
            }
        }
    });
}

From source file:com.manning.androidhacks.hack043.service.NoBatchService.java

@Override
protected void onHandleIntent(Intent intent) {

    ContentResolver contentResolver = getContentResolver();
    contentResolver.delete(NoBatchNumbersContentProvider.CONTENT_URI, null, null);

    for (int i = 1; i <= 100; i++) {
        ContentValues cv = new ContentValues();
        cv.put(NoBatchNumbersContentProvider.COLUMN_TEXT, "" + i);
        contentResolver.insert(NoBatchNumbersContentProvider.CONTENT_URI, cv);
    }//w  w w .  j av a 2  s  .co m
}

From source file:cn.code.notes.gtask.data.SqlConn.java

public SqlConn(Context context) {
    mContentResolver = context.getContentResolver();
    mIsCreate = true;//from  ww  w .ja  v a 2 s .  co m
    mGuid = "";
    mId = INVALID_ID;
    mDataMD5 = "";
    mDiffDataValues = new ContentValues();
}

From source file:com.rs.TCOfflineStatementCollection.java

/**
 * addStatement takes a statement and adds it to the local database
 * @param statement// w ww  .jav a2 s  .  co  m
 * @param addInterface
 */
public void addStatement(Statement statement, addStatementInterface addInterface) {
    _statementArray.add(statement);

    Long now = Long.valueOf(System.currentTimeMillis());

    ContentValues initialValues = new ContentValues();
    try {
        initialValues.put(LocalStatements.CREATE_DATE, now);
        initialValues.put(LocalStatements.STATEMENT_JSON, statement.toJSON());
        initialValues.put(LocalStatements.QUERY_STRING, "");
        initialValues.put(LocalStatements.STATEMENT_ID, statement.getId().toString());
    } catch (Exception e) {
        addInterface.errorBlock("initialValues" + e.toString());
        return;
    }

    try {
        appContext.getContentResolver().insert(LocalStatements.CONTENT_URI, initialValues);
    } catch (Exception e) {
        addInterface.errorBlock("insert" + e.toString());
        return;
    }

    addInterface.completionBlock();
}

From source file:com.yozio.android.YozioDataStoreImpl.java

public boolean addEvent(JSONObject event) {
    synchronized (this) {
        try {/*  w w w  .  j a v a 2s.  co m*/
            ContentValues cv = new ContentValues();
            cv.put(APP_KEY, appKey);
            cv.put(DATA, event.toString());
            dbHelper.getWritableDatabase().insert(EVENTS_TABLE, null, cv);
            if (listener != null) {
                listener.onAdd();
            }
            // Don't worry, finally will still be called.
            return true;
        } catch (SQLiteException e) {
            Log.e(LOGTAG, "addEvent", e);
        } finally {
            dbHelper.close();
        }
    }
    return false;
}

From source file:com.google.samples.apps.iosched.feedback.FeedbackHelper.java

/**
 * Saves the session feedback using the appropriate content provider, and dismisses the
 * feedback notification.//from  w  w w.  ja  v a  2s.  c  o m
 */
public void saveSessionFeedback(SessionFeedbackData data) {
    if (null == data.comments) {
        data.comments = "";
    }

    String answers = data.sessionId + ", " + data.sessionRating + ", " + data.sessionRelevantAnswer + ", "
            + data.contentAnswer + ", " + data.speakerAnswer + ", " + data.comments;
    LOGD(TAG, answers);

    ContentValues values = new ContentValues();
    values.put(ScheduleContract.Feedback.SESSION_ID, data.sessionId);
    values.put(ScheduleContract.Feedback.UPDATED, System.currentTimeMillis());
    values.put(ScheduleContract.Feedback.SESSION_RATING, data.sessionRating);
    values.put(ScheduleContract.Feedback.ANSWER_RELEVANCE, data.sessionRelevantAnswer);
    values.put(ScheduleContract.Feedback.ANSWER_CONTENT, data.contentAnswer);
    values.put(ScheduleContract.Feedback.ANSWER_SPEAKER, data.speakerAnswer);
    values.put(ScheduleContract.Feedback.COMMENTS, data.comments);

    Uri uri = mContext.getContentResolver().insert(ScheduleContract.Feedback.buildFeedbackUri(data.sessionId),
            values);
    LOGD(TAG, null == uri ? "No feedback was saved" : uri.toString());
    dismissFeedbackNotification(data.sessionId);
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.ProfilePictureObj.java

public boolean handleObjFromNetwork(Context context, Contact from, JSONObject obj) {
    byte[] data = FastBase64.decode(obj.optString(DATA));
    boolean reply = obj.optBoolean(REPLY);

    String id = Long.toString(from.id);
    ContentValues values = new ContentValues();
    values.put(Contact.PICTURE, data);/*from  w ww . j  a v a 2  s  .c  om*/
    context.getContentResolver().update(Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts"), values,
            "_id=?", new String[] { id });
    Helpers.invalidateContacts();

    if (reply) {
        LinkedList<Contact> contacts = new LinkedList<Contact>();
        contacts.add(from);
        Helpers.resendProfile(context, contacts, false);
    }
    return false;
}

From source file:com.liferay.alerts.model.User.java

@Override
public ContentValues toContentValues() {
    ContentValues values = new ContentValues();

    values.put(ID, _id);//from  w ww  .j a v  a 2 s. c  o m
    values.put(UUID, _uuid);
    values.put(FULL_NAME, _fullName);
    values.put(PORTRAIT_ID, _portraitId);

    return values;
}