List of usage examples for android.content ContentResolver insert
public final @Nullable Uri insert(@RequiresPermission.Write @NonNull Uri url, @Nullable ContentValues values)
From source file:Main.java
public static void addCallLog(Context context, ContentValues values, ContentValues extraValues) { ContentResolver contentResolver = context.getContentResolver(); Uri result = contentResolver.insert(CallLog.Calls.CONTENT_URI, values); if (result != null) { // Announce that to other apps final Intent broadcast = new Intent(ACTION_ANNOUNCE_SIP_CALLLOG); broadcast.putExtra(EXTRA_CALL_LOG_URI, result.toString()); String provider = extraValues.getAsString(EXTRA_SIP_PROVIDER); if (provider != null) { broadcast.putExtra(EXTRA_SIP_PROVIDER, provider); }//from w w w . j a v a2s . com context.sendBroadcast(broadcast); } }
From source file:com.ksk.droidbatterybooster.provider.PowerSchedule.java
/** * Creates a new time schedule and fills in the given schedule's id. *//*from w ww . j a v a2 s . c om*/ public static PowerSchedule addSchedule(ContentResolver contentResolver, PowerSchedule schedule) { ContentValues values = createContentValues(schedule); Uri uri = contentResolver.insert(CONTENT_URI, values); schedule.id = getId(uri); return schedule; }
From source file:com.ksk.droidbatterybooster.provider.OptimalMode.java
public static OptimalMode addMode(ContentResolver contentResolver, OptimalMode mode) { ContentValues values = createContentValues(mode); Uri uri = contentResolver.insert(CONTENT_URI, values); mode.id = getModeId(uri);//w ww.j av a 2 s . c o m return mode; }
From source file:com.silentcorp.autotracker.db.VehicleDB.java
/** * Create new vehicle/* www . j a va 2s . co m*/ * * @param contentResolver * @param vehicle */ public static void createVehicle(Context context, VehicleBean vehicle) { ContentValues values = getAsContentValues(vehicle); ContentResolver contentResolver = context.getContentResolver(); contentResolver.insert(DBContentProvider.VEHICLES_URI, values); }
From source file:saphion.batterycaster.providers.Alarm.java
public static Alarm addAlarm(ContentResolver contentResolver, Alarm alarm) { ContentValues values = createContentValues(alarm); Uri uri = contentResolver.insert(CONTENT_URI, values); alarm.id = getId(uri);/* w w w . ja va 2s . c o m*/ return alarm; }
From source file:Main.java
public static void addCallToLog(ContentResolver contentResolver, String number, long duration, int type, long time) { ContentValues values = new ContentValues(); values.put(Calls.NUMBER, number);/*from ww w .ja v a 2s. c om*/ values.put(Calls.DATE, time); values.put(Calls.DURATION, duration); values.put(Calls.TYPE, type); values.put(Calls.NEW, 1); values.put(Calls.CACHED_NAME, ""); values.put(Calls.CACHED_NUMBER_TYPE, 0); values.put(Calls.CACHED_NUMBER_LABEL, ""); contentResolver.insert(Calls.CONTENT_URI, values); }
From source file:fr.mixit.android.utils.SyncUtils.java
public static void updateLocalMd5(ContentResolver resolver, String url, String md5) { final String syncId = MixItContract.Sync.generateSyncId(url); final ContentValues contentValues = new ContentValues(); contentValues.put(MixItContract.Sync.URI_ID, syncId); contentValues.put(MixItContract.Sync.URI, url); contentValues.put(MixItContract.Sync.MD5, md5); resolver.insert(MixItContract.Sync.CONTENT_URI, contentValues); }
From source file:android.provider.Checkin.java
/** * Helper function to update statistics in the database. * Note that multiple updates to the same tag will be combined. * * @param tag identifying what is being observed * @param count of occurrences//from ww w . j ava 2 s .co m * @param sum of some value over these occurrences * @return URI of the statistic that was returned */ static public Uri updateStats(ContentResolver resolver, Stats.Tag tag, int count, double sum) { try { ContentValues values = new ContentValues(); values.put(Stats.TAG, tag.toString()); if (count != 0) values.put(Stats.COUNT, count); if (sum != 0.0) values.put(Stats.SUM, sum); return resolver.insert(Stats.CONTENT_URI, values); } catch (SQLException e) { Log.e(TAG, "Can't update stat: " + tag, e); // Database errors are not fatal. return null; } }
From source file:android.provider.Checkin.java
/** * Helper function to log an event to the database. * * @param resolver from {@link android.content.Context#getContentResolver} * @param tag identifying the type of event being recorded * @param value associated with event, if any * @return URI of the event that was added *//* w w w. jav a2s . c o m*/ static public Uri logEvent(ContentResolver resolver, Events.Tag tag, String value) { try { // Don't specify the date column; the content provider will add that. ContentValues values = new ContentValues(); values.put(Events.TAG, tag.toString()); if (value != null) values.put(Events.VALUE, value); return resolver.insert(Events.CONTENT_URI, values); } catch (SQLException e) { Log.e(TAG, "Can't log event: " + tag, e); // Database errors are not fatal. return null; } }
From source file:saphion.batterycaster.providers.Alarm.java
public static Alarm addAlarm(ContentResolver contentResolver, AlarmItems alarmItems) { Alarm alarm = new Alarm(alarmItems); ContentValues values = createContentValues(alarm); Uri uri = contentResolver.insert(CONTENT_URI, values); alarm.id = getId(uri);//from ww w. j av a2 s .c om return alarm; }