Search in sources :

Example 46 with ContentResolver

use of android.content.ContentResolver in project platform_packages_apps_launcher by android.

the class LauncherModel method getFolderById.

FolderInfo getFolderById(Context context, long id) {
    final ContentResolver cr = context.getContentResolver();
    Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, null, "_id=? and (itemType=? or itemType=?)", new String[] { String.valueOf(id), String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER), String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER) }, null);
    try {
        if (c.moveToFirst()) {
            final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
            final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
            final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
            final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
            final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
            final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
            FolderInfo folderInfo = null;
            switch(c.getInt(itemTypeIndex)) {
                case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER:
                    folderInfo = findOrMakeUserFolder(mFolders, id);
                    break;
                case LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER:
                    folderInfo = findOrMakeLiveFolder(mFolders, id);
                    break;
            }
            folderInfo.title = c.getString(titleIndex);
            folderInfo.id = id;
            folderInfo.container = c.getInt(containerIndex);
            folderInfo.screen = c.getInt(screenIndex);
            folderInfo.cellX = c.getInt(cellXIndex);
            folderInfo.cellY = c.getInt(cellYIndex);
            return folderInfo;
        }
    } finally {
        c.close();
    }
    return null;
}
Also used : Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Example 47 with ContentResolver

use of android.content.ContentResolver in project platform_packages_apps_launcher by android.

the class LauncherModel method deleteGestureFromDatabase.

static void deleteGestureFromDatabase(Context context, ItemInfo item) {
    final ContentResolver cr = context.getContentResolver();
    cr.delete(LauncherSettings.Gestures.getContentUri(item.id, false), null, null);
}
Also used : ContentResolver(android.content.ContentResolver)

Example 48 with ContentResolver

use of android.content.ContentResolver in project platform_packages_apps_launcher by android.

the class LauncherModel method addItemToDatabase.

/**
     * Add an item to the database in a specified container. Sets the container, screen, cellX and
     * cellY fields of the item. Also assigns an ID to the item.
     */
static void addItemToDatabase(Context context, ItemInfo item, long container, int screen, int cellX, int cellY, boolean notify) {
    item.container = container;
    item.screen = screen;
    item.cellX = cellX;
    item.cellY = cellY;
    final ContentValues values = new ContentValues();
    final ContentResolver cr = context.getContentResolver();
    item.onAddToDatabase(values);
    Uri result = cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI : LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);
    if (result != null) {
        item.id = Integer.parseInt(result.getPathSegments().get(1));
    }
}
Also used : ContentValues(android.content.ContentValues) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 49 with ContentResolver

use of android.content.ContentResolver in project platform_packages_apps_launcher by android.

the class LauncherModel method deleteUserFolderContentsFromDatabase.

/**
     * Remove the contents of the specified folder from the database
     */
static void deleteUserFolderContentsFromDatabase(Context context, UserFolderInfo info) {
    final ContentResolver cr = context.getContentResolver();
    cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null);
    cr.delete(LauncherSettings.Favorites.CONTENT_URI, LauncherSettings.Favorites.CONTAINER + "=" + info.id, null);
}
Also used : ContentResolver(android.content.ContentResolver)

Example 50 with ContentResolver

use of android.content.ContentResolver in project platform_frameworks_base by android.

the class HdmiControlService method writeBooleanSetting.

void writeBooleanSetting(String key, boolean value) {
    ContentResolver cr = getContext().getContentResolver();
    Global.putInt(cr, key, toInt(value));
}
Also used : ContentResolver(android.content.ContentResolver)

Aggregations

ContentResolver (android.content.ContentResolver)1198 Uri (android.net.Uri)243 Cursor (android.database.Cursor)196 ContentValues (android.content.ContentValues)116 Intent (android.content.Intent)94 RemoteException (android.os.RemoteException)67 IOException (java.io.IOException)62 Context (android.content.Context)58 ArrayList (java.util.ArrayList)50 File (java.io.File)48 Resources (android.content.res.Resources)46 ComponentName (android.content.ComponentName)44 MediumTest (android.test.suitebuilder.annotation.MediumTest)37 PreferenceScreen (android.support.v7.preference.PreferenceScreen)35 Bitmap (android.graphics.Bitmap)33 ContentObserver (android.database.ContentObserver)28 FileNotFoundException (java.io.FileNotFoundException)28 PendingIntent (android.app.PendingIntent)25 MockContentResolver (android.test.mock.MockContentResolver)25 AssetFileDescriptor (android.content.res.AssetFileDescriptor)24