当前位置: 首页>>代码示例>>Java>>正文


Java ContentResolver.update方法代码示例

本文整理汇总了Java中android.content.ContentResolver.update方法的典型用法代码示例。如果您正苦于以下问题:Java ContentResolver.update方法的具体用法?Java ContentResolver.update怎么用?Java ContentResolver.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentResolver的用法示例。


在下文中一共展示了ContentResolver.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateBrightness

import android.content.ContentResolver; //导入方法依赖的package包/类
public int updateBrightness(int progress)
   {
       ContentValues values = new ContentValues(1);
       ContentResolver cr = mcontext.getContentResolver();
       Uri brightnessUri = Settings.System.CONTENT_URI;
       int result = 0;


       Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, progress);

       values.put("screen_brightness", progress); 

       try
{
    result = cr.update(brightnessUri, values, null, null);
       }
catch (Exception e)
{
    result = 0;
       }  
       return result;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:23,代码来源:EnergyWrapper.java

示例2: updateBacklightTime

import android.content.ContentResolver; //导入方法依赖的package包/类
public void updateBacklightTime(int time)
   {    	
       ContentValues values = new ContentValues(1);
       ContentResolver cr = mcontext.getContentResolver();
       Uri blTimeUri = Settings.System.CONTENT_URI;
       int result;

       //Log.v("updateBacklightTime", "num:" + time);
       Settings.System.putInt(cr, Settings.System.SCREEN_OFF_TIMEOUT, time);
//  Log.v("updateBacklightTime", "putINTOK");

       values.put("screen_off_timeout", time); 

       try
{
    result = cr.update(blTimeUri, values, null, null);
       }
catch (Exception e)
{
    result = 0;
       }  
//   Log.v("Result", "result is:" + result);      	
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:24,代码来源:EnergyWrapper.java

示例3: markHiddenValue

import android.content.ContentResolver; //导入方法依赖的package包/类
public static void markHiddenValue(Context context, Long[] videoIds, int value) {
    Log.d(TAG, "markHiddenValue "+videoIds+" "+value);
    final ContentResolver cr = context.getContentResolver();
    final ContentValues values = new ContentValues(1);
    values.put(VideoStore.Video.VideoColumns.ARCHOS_HIDDEN_BY_USER, value);
    String whereString ="";
    String [] whereArg = new String[videoIds.length];
    int i = 0;
    for (long id : videoIds) {
        if(!whereString.isEmpty())
            whereString+= " OR ";
        whereString += VideoStore.Video.VideoColumns._ID+ " = ?";
        whereArg[i] = Long.toString(id);
        i++;
    }
    cr.update(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, values,
            whereString,
            whereArg);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:20,代码来源:DbUtils.java

示例4: renamePlaylist

import android.content.ContentResolver; //导入方法依赖的package包/类
/**
 * Rename Playlist
 *
 * @param context
 * @param newplaylist
 * @param playlist_id
 */
public static void renamePlaylist(Context context, String newplaylist, long playlist_id) {
    if (permissionManager.writeExternalStorageGranted(context)) {
        Uri newuri = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
        ContentResolver resolver = context.getContentResolver();
        ContentValues values = new ContentValues();
        String where = MediaStore.Audio.Playlists._ID + " =? ";
        String[] whereVal = {Long.toString(playlist_id)};
        values.put(MediaStore.Audio.Playlists.NAME, newplaylist);
        resolver.update(newuri, values, where, whereVal);
    } else {
        Log.e("PlaylistHelper", "Permission failed");
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:21,代码来源:PlaylistHelper.java

示例5: deleteSelectedLabels

import android.content.ContentResolver; //导入方法依赖的package包/类
private void deleteSelectedLabels(){
    ContentResolver resolver = getContext().getContentResolver();
    int size = selectedIds.size();
    Long[] mArray = new Long[size];
    for (int i = 0; i < size; i++) {
        long id = selectedIds.keyAt(i);
        mArray[i] = id;
    }
    // Update affected entries by label deletion
    ContentValues cv = new ContentValues();
    cv.putNull(ToduleDBContract.TodoEntry.COLUMN_NAME_LABEL);
    String select = ToduleDBContract.TodoEntry.COLUMN_NAME_LABEL +  " IN(" + constructPlaceholders(mArray.length)+ ")";
    String[] selectionArgs = new String[mArray.length];
    for (int i =0; i< mArray.length; i++){
        selectionArgs[i] = String.valueOf(mArray[i]);
    }
    resolver.update(ToduleDBContract.TodoEntry.CONTENT_URI, cv, select ,selectionArgs);

    // Delete label from db
    select = TodoLabel._ID + " IN(" + constructPlaceholders(mArray.length)+ ")";
    int count = resolver.delete(TodoLabel.CONTENT_URI, select, selectionArgs);
    Toast.makeText(myActivity, String.valueOf(count) + " label deleted", Toast.LENGTH_SHORT).show();
}
 
开发者ID:danlls,项目名称:Todule-android,代码行数:24,代码来源:ToduleLabelFragment.java

示例6: updateModuleisAdd

import android.content.ContentResolver; //导入方法依赖的package包/类
public static void updateModuleisAdd(ContentResolver resolver, String funcode, String isAdd)
{
    Uri mCardViewUrl = ModuleTable.CONTENT_URI;
    
    ContentValues Moduelvalues = new ContentValues();
    String openId = GlobalState.getInstance().getOpenId();
    Moduelvalues.put(ModuleTable.ISADD, isAdd);
    if (isAdd.equals("" + Constant_Mgr.No_Add_1))
    {
        Moduelvalues.put(ModuleTable.SORT_IN_ADDLIST, 999);
    }
    
    resolver.update(mCardViewUrl,
        Moduelvalues,
        ModuleTable.OPENID + "=? and " + ModuleTable.FUNCODE + "=? ",
        new String[] {openId, funcode});
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:18,代码来源:ModuleDBUtils.java

示例7: updateItemInDatabaseHelper

import android.content.ContentResolver; //导入方法依赖的package包/类
static void updateItemInDatabaseHelper(Context context, final ContentValues values,
        final ItemInfo item, final String callingFunction) {
    final long itemId = item.id;
    final Uri uri = LauncherSettings.Favorites.getContentUri(itemId);
    final ContentResolver cr = context.getContentResolver();

    final StackTraceElement[] stackTrace = new Throwable().getStackTrace();

    Runnable r = new Runnable() {
        public void run() {
            cr.update(uri, values, null, null);
            updateItemArrays(item, itemId, stackTrace);
        }
    };
    runOnWorkerThread(r);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:LauncherModel.java

示例8: setRingtone

import android.content.ContentResolver; //导入方法依赖的package包/类
public static void setRingtone(AppCompatActivity context, long id) {
    if (!checkSystemWritePermission(context)) return;

    ContentResolver resolver = context.getContentResolver();
    Uri ringUri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);

    try {
        ContentValues values = new ContentValues(2);
        values.put(MediaStore.Audio.Media.IS_RINGTONE, "1");
        values.put(MediaStore.Audio.Media.IS_ALARM, "1");
        resolver.update(ringUri, values, null, null);
    } catch (UnsupportedOperationException ex) {
        Log.e("Notset", "couldn't set ringtone flag for id " + id);
        return;
    }

    String[] cols = new String[]{
            MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.TITLE
    };

    String where = MediaStore.Audio.Media._ID + "=" + id;
    Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            cols, where, null, null);
    try {
        if (cursor != null && cursor.getCount() == 1) {
            cursor.moveToFirst();
            Settings.System.putString(resolver, Settings.System.RINGTONE, ringUri.toString());
            String message = context.getString(R.string.ringtone_set);
            String filename = '"' + cursor.getString(2) + '"';
            Toast.makeText(context, filename + " " + message, Toast.LENGTH_SHORT).show();
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:40,代码来源:MusicUtils.java

示例9: restorePreferredApn

import android.content.ContentResolver; //导入方法依赖的package包/类
private static void restorePreferredApn(Context context, SharedPreferences prefs) {
	
	long id = getPreferedApnIdFromProvider(context);
	if (id == -1L) {
		id = getPreferedApnIdFromPreferences(context, prefs);
		if (id == -1L) {
			id = getFirstCurrentApnId(context);
		}
	}
	
	if (id == -1L) {
		Log.d(TAG, "No prefered APN can be restored");
	} else {
		
		ContentResolver resolver = context.getContentResolver();
		
		// refresh preferred APN
		
        ContentValues values = new ContentValues();
        values.putNull(COLUMN_APN_ID);
        resolver.update(PREFERRED_APN, values, null, null);
        
        values.put(COLUMN_APN_ID, id);
        resolver.update(PREFERRED_APN, values, null, null);
		
		Log.d(TAG, "Restored prefered APN id=" + id);
	}
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:29,代码来源:ApnControl.java

示例10: deleteCrashingCalendars

import android.content.ContentResolver; //导入方法依赖的package包/类
@SuppressWarnings("MissingPermission") // already requested in calling method
private void deleteCrashingCalendars(ContentResolver contentResolver) {
    // first find any faulty Calendars
    final String fixingAccountName = "FixingAccountName";
    String selection = CalendarContract.Calendars.ACCOUNT_NAME + " IS NULL";
    Uri uri = CalendarContract.Calendars.CONTENT_URI;
    uri = uri.buildUpon()
            .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
            .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, fixingAccountName)
            .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
            .build();
    ContentValues values = new ContentValues();
    values.put(CalendarContract.Calendars.ACCOUNT_NAME, fixingAccountName);
    values.put(CalendarContract.Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL);
    int count = contentResolver.update(uri, values, selection, null);

    // now delete any faulty Calendars
    if (count > 0) {
        Uri evuri = CalendarContract.Calendars.CONTENT_URI;
        Cursor result = contentResolver.query(evuri, new String[]{CalendarContract.Calendars._ID, CalendarContract.Calendars.ACCOUNT_NAME}, null, null, null);
        if (result != null) {
            while (result.moveToNext()) {
                if (result.getString(1).equals(fixingAccountName)) {
                    long calid = result.getLong(0);
                    Uri deleteUri = ContentUris.withAppendedId(evuri, calid);
                    contentResolver.delete(deleteUri, null, null);
                }
            }
            result.close();
        }
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:33,代码来源:AbstractCalendarAccessor.java

示例11: updateServerDb

import android.content.ContentResolver; //导入方法依赖的package包/类
private final static void updateServerDb(long id, ContentResolver cr, int oldState,
        int newState, long time) {
    if (oldState == newState) return;
    ContentValues cv = new ContentValues();
    cv.put(MusicStore.SmbServer.SmbServerColumns.ACTIVE, String.valueOf(newState));
    if (newState != 0) {
        // update last seen only if it's active now
        cv.put(MusicStore.SmbServer.SmbServerColumns.LAST_SEEN, String.valueOf(time));
    }
    String[] selectionArgs = new String[] {
        String.valueOf(id)
    };
    if (DBG) Log.d(TAG, "DB: update server: " + id + " values:" + cv);
    cr.update(SERVER_URI, cv, SELECTION_ID, selectionArgs);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:16,代码来源:SmbStateService.java

示例12: wipeCollection

import android.content.ContentResolver; //导入方法依赖的package包/类
private Trakt.Result wipeCollection() {
    final ContentResolver cr = getContentResolver();
    ContentValues values = new ContentValues(1);
    values.put(VideoStore.Video.VideoColumns.ARCHOS_TRAKT_LIBRARY, 0);
    cr.update(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, values, WIPE_COLLECTION_SELECTION, null);
    return Trakt.Result.getSuccess();
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:8,代码来源:TraktService.java

示例13: wipe

import android.content.ContentResolver; //导入方法依赖的package包/类
private Trakt.Result wipe() {
    unregisterReceiver();

    // wipe trakt* from db
    final ContentResolver cr = getContentResolver();
    ContentValues values = new ContentValues(2);
    values.put(VideoStore.Video.VideoColumns.ARCHOS_TRAKT_SEEN, 0);
    values.put(VideoStore.Video.VideoColumns.ARCHOS_TRAKT_LIBRARY, 0);
    cr.update(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, values, WIPE_SELECTION, null);
    return Trakt.Result.getSuccess();
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:12,代码来源:TraktService.java

示例14: updateName

import android.content.ContentResolver; //导入方法依赖的package包/类
public static void updateName(ContentResolver Cr, String str, String name) {
    Uri uri = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;

    ContentValues values = new ContentValues();
    values.put(MediaStore.Audio.Playlists.NAME, str);

    int Got = Cr.update(uri, values,MediaStore.Audio.Playlists.NAME + " = ?" ,new String[]{name});
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:9,代码来源:playlistHandler.java

示例15: update

import android.content.ContentResolver; //导入方法依赖的package包/类
/**
 * Updates the repo metadata in the database.  All data comes from the
 * index file except {@link Repo#id}, which is generated by the database.
 * That makes for an two cycle workflow, where first this must be called
 * to fetch the {@code Repo.id} from the database, then it is called a
 * second time to actually set the repo metadata.
 */
public static void update(Context context, Repo repo, ContentValues values) {
    ContentResolver resolver = context.getContentResolver();

    // Change the name to the new address. Next time we update the repo
    // index file, it will populate the name field with the proper
    // name, but the best we can do is guess right now.
    if (values.containsKey(Cols.ADDRESS) &&
            !values.containsKey(Cols.NAME)) {
        String name = Repo.addressToName(values.getAsString(Cols.ADDRESS));
        values.put(Cols.NAME, name);
    }

    /*
     * If the repo is signed and has a public key, then guarantee that
     * the fingerprint is also set. The stored fingerprint is checked
     * when a repo URI is received by FDroid to prevent bad actors from
     * overriding repo configs with other keys. So if the fingerprint is
     * not stored yet, calculate it and store it. If the fingerprint is
     * stored, then check it against the calculated fingerprint just to
     * make sure it is correct. If the fingerprint is empty, then store
     * the calculated one.
     */
    if (values.containsKey(Cols.SIGNING_CERT)) {
        String publicKey = values.getAsString(Cols.SIGNING_CERT);
        String calcedFingerprint = Utils.calcFingerprint(publicKey);
        if (values.containsKey(Cols.FINGERPRINT)) {
            String fingerprint = values.getAsString(Cols.FINGERPRINT);
            if (!TextUtils.isEmpty(publicKey)) {
                if (TextUtils.isEmpty(fingerprint)) {
                    values.put(Cols.FINGERPRINT, calcedFingerprint);
                } else if (!fingerprint.equals(calcedFingerprint)) {
                    // TODO the UI should represent this error!
                    Log.e(TAG, "The stored and calculated fingerprints do not match!");
                    Log.e(TAG, "Stored: " + fingerprint);
                    Log.e(TAG, "Calculated: " + calcedFingerprint);
                }
            }
        } else if (!TextUtils.isEmpty(publicKey)) {
            // no fingerprint in 'values', so put one there
            values.put(Cols.FINGERPRINT, calcedFingerprint);
        }
    }

    if (values.containsKey(Cols.IN_USE)) {
        Integer inUse = values.getAsInteger(Cols.IN_USE);
        if (inUse != null && inUse == 0) {
            values.put(Cols.LAST_ETAG, (String) null);
        }
    }

    final Uri uri = getContentUri(repo.getId());
    final String[] args = {Long.toString(repo.getId())};
    resolver.update(uri, values, Cols._ID + " = ?", args);
    repo.setValues(values);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:63,代码来源:RepoProvider.java


注:本文中的android.content.ContentResolver.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。