當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentResolver.applyBatch方法代碼示例

本文整理匯總了Java中android.content.ContentResolver.applyBatch方法的典型用法代碼示例。如果您正苦於以下問題:Java ContentResolver.applyBatch方法的具體用法?Java ContentResolver.applyBatch怎麽用?Java ContentResolver.applyBatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.ContentResolver的用法示例。


在下文中一共展示了ContentResolver.applyBatch方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateItemsInDatabaseHelper

import android.content.ContentResolver; //導入方法依賴的package包/類
static void updateItemsInDatabaseHelper(Context context, final ArrayList<ContentValues> valuesList,
        final ArrayList<ItemInfo> items, final String callingFunction) {
    final ContentResolver cr = context.getContentResolver();

    final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
    Runnable r = new Runnable() {
        public void run() {
            ArrayList<ContentProviderOperation> ops =
                    new ArrayList<ContentProviderOperation>();
            int count = items.size();
            for (int i = 0; i < count; i++) {
                ItemInfo item = items.get(i);
                final long itemId = item.id;
                final Uri uri = LauncherSettings.Favorites.getContentUri(itemId);
                ContentValues values = valuesList.get(i);

                ops.add(ContentProviderOperation.newUpdate(uri).withValues(values).build());
                updateItemArrays(item, itemId, stackTrace);

            }
            try {
                cr.applyBatch(LauncherProvider.AUTHORITY, ops);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    runOnWorkerThread(r);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:30,代碼來源:LauncherModel.java

示例2: deleteMultipleContactsAtOnce

import android.content.ContentResolver; //導入方法依賴的package包/類
public void deleteMultipleContactsAtOnce(List<String> ids) {
	String select = Data.CONTACT_ID + " = ?";
	ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

	for (String id : ids) {
		String[] args = new String[] { id };
		ops.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI).withSelection(select, args).build());
	}

	ContentResolver cr = ContactsManager.getInstance().getContentResolver();
	try {
		cr.applyBatch(ContactsContract.AUTHORITY, ops);
	} catch (Exception e) {
		Log.e(e);
	}
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:17,代碼來源:ContactsManager.java

示例3: updateWorkspaceScreenOrder

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Update the order of the workspace screens in the database. The array list contains
 * a list of screen ids in the order that they should appear.
 */
public static void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
    final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
    final ContentResolver cr = context.getContentResolver();
    final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;

    // Remove any negative screen ids -- these aren't persisted
    Iterator<Long> iter = screensCopy.iterator();
    while (iter.hasNext()) {
        long id = iter.next();
        if (id < 0) {
            iter.remove();
        }
    }

    Runnable r = new Runnable() {
        @Override
        public void run() {
            ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
            // Clear the table
            ops.add(ContentProviderOperation.newDelete(uri).build());
            int count = screensCopy.size();
            for (int i = 0; i < count; i++) {
                ContentValues v = new ContentValues();
                long screenId = screensCopy.get(i);
                v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
                v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
                ops.add(ContentProviderOperation.newInsert(uri).withValues(v).build());
            }

            try {
                cr.applyBatch(LauncherProvider.AUTHORITY, ops);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }

            synchronized (sBgDataModel) {
                sBgDataModel.workspaceScreens.clear();
                sBgDataModel.workspaceScreens.addAll(screensCopy);
            }
        }
    };
    runOnWorkerThread(r);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:48,代碼來源:LauncherModel.java

示例4: updateWorkspaceScreenOrder

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * Update the order of the workspace screens in the database. The array list contains
 * a list of screen ids in the order that they should appear.
 */
public void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
    final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
    final ContentResolver cr = context.getContentResolver();
    final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;

    // Remove any negative screen ids -- these aren't persisted
    Iterator<Long> iter = screensCopy.iterator();
    while (iter.hasNext()) {
        long id = iter.next();
        if (id < 0) {
            iter.remove();
        }
    }

    Runnable r = new Runnable() {
        @Override
        public void run() {
            ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
            // Clear the table
            ops.add(ContentProviderOperation.newDelete(uri).build());
            int count = screensCopy.size();
            for (int i = 0; i < count; i++) {
                ContentValues v = new ContentValues();
                long screenId = screensCopy.get(i);
                v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
                v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
                ops.add(ContentProviderOperation.newInsert(uri).withValues(v).build());
            }

            try {
                cr.applyBatch(LauncherProvider.AUTHORITY, ops);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }

            synchronized (sBgLock) {
                sBgWorkspaceScreens.clear();
                sBgWorkspaceScreens.addAll(screensCopy);
            }
        }
    };
    runOnWorkerThread(r);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:48,代碼來源:LauncherModel.java


注:本文中的android.content.ContentResolver.applyBatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。