Java Code Examples for android.content.ContentValues#getAsBoolean()

The following examples show how to use android.content.ContentValues#getAsBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeBrowserProvider.java    From android-chromium with BSD 2-Clause "Simplified" License 7 votes vote down vote up
private long addBookmark(ContentValues values) {
    String url = values.getAsString(Browser.BookmarkColumns.URL);
    String title = values.getAsString(Browser.BookmarkColumns.TITLE);
    boolean isFolder = false;
    if (values.containsKey(BOOKMARK_IS_FOLDER_PARAM)) {
        isFolder = values.getAsBoolean(BOOKMARK_IS_FOLDER_PARAM);
    }
    long parentId = INVALID_BOOKMARK_ID;
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    long id = nativeAddBookmark(mNativeChromeBrowserProvider, url, title, isFolder, parentId);
    if (id == INVALID_BOOKMARK_ID) return id;

    if (isFolder) {
        updateLastModifiedBookmarkFolder(id);
    } else {
        updateLastModifiedBookmarkFolder(parentId);
    }
    return id;
}
 
Example 2
Source File: ChromeBrowserProvider.java    From delion with Apache License 2.0 6 votes vote down vote up
private long addBookmark(ContentValues values) {
    String url = values.getAsString(BookmarkColumns.URL);
    String title = values.getAsString(BookmarkColumns.TITLE);
    boolean isFolder = false;
    if (values.containsKey(BOOKMARK_IS_FOLDER_PARAM)) {
        isFolder = values.getAsBoolean(BOOKMARK_IS_FOLDER_PARAM);
    }
    long parentId = INVALID_BOOKMARK_ID;
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    long id = nativeAddBookmark(mNativeChromeBrowserProvider, url, title, isFolder, parentId);
    if (id == INVALID_BOOKMARK_ID) return id;

    if (isFolder) {
        updateLastModifiedBookmarkFolder(id);
    } else {
        updateLastModifiedBookmarkFolder(parentId);
    }
    return id;
}
 
Example 3
Source File: ChromeBrowserProvider.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private long addBookmark(ContentValues values) {
    String url = values.getAsString(BookmarkColumns.URL);
    String title = values.getAsString(BookmarkColumns.TITLE);
    boolean isFolder = false;
    if (values.containsKey(BOOKMARK_IS_FOLDER_PARAM)) {
        isFolder = values.getAsBoolean(BOOKMARK_IS_FOLDER_PARAM);
    }
    long parentId = INVALID_BOOKMARK_ID;
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    long id = nativeAddBookmark(mNativeChromeBrowserProvider, url, title, isFolder, parentId);
    if (id == INVALID_BOOKMARK_ID) return id;

    if (isFolder) {
        updateLastModifiedBookmarkFolder(id);
    } else {
        updateLastModifiedBookmarkFolder(parentId);
    }
    return id;
}
 
Example 4
Source File: ChromeBrowserProvider.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private long addBookmark(ContentValues values) {
    String url = values.getAsString(BookmarkColumns.URL);
    String title = values.getAsString(BookmarkColumns.TITLE);
    boolean isFolder = false;
    if (values.containsKey(BOOKMARK_IS_FOLDER_PARAM)) {
        isFolder = values.getAsBoolean(BOOKMARK_IS_FOLDER_PARAM);
    }
    long parentId = INVALID_BOOKMARK_ID;
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    long id = nativeAddBookmark(mNativeChromeBrowserProvider, url, title, isFolder, parentId);
    if (id == INVALID_BOOKMARK_ID) return id;

    if (isFolder) {
        updateLastModifiedBookmarkFolder(id);
    } else {
        updateLastModifiedBookmarkFolder(parentId);
    }
    return id;
}
 
Example 5
Source File: CategoryHandler.java    From opentasks with Apache License 2.0 6 votes vote down vote up
/**
 * Check if a category with matching {@link ContentValues} exists and returns the existing category or creates a new category in the database.
 *
 * @param db
 *         The {@link SQLiteDatabase}.
 * @param values
 *         The {@link ContentValues} of the category.
 *
 * @return The {@link ContentValues} of the existing or new category.
 */
private ContentValues getOrInsertCategory(SQLiteDatabase db, ContentValues values)
{
    if (values.getAsBoolean(IS_NEW_CATEGORY))
    {
        // insert new category in category table
        ContentValues newCategoryValues = new ContentValues(4);
        newCategoryValues.put(Categories.ACCOUNT_NAME, values.getAsString(Categories.ACCOUNT_NAME));
        newCategoryValues.put(Categories.ACCOUNT_TYPE, values.getAsString(Categories.ACCOUNT_TYPE));
        newCategoryValues.put(Categories.NAME, values.getAsString(Category.CATEGORY_NAME));
        newCategoryValues.put(Categories.COLOR, values.getAsInteger(Category.CATEGORY_COLOR));

        long categoryID = db.insert(Tables.CATEGORIES, "", newCategoryValues);
        values.put(Category.CATEGORY_ID, categoryID);
    }

    // remove redundant values
    values.remove(IS_NEW_CATEGORY);
    values.remove(Categories.ACCOUNT_NAME);
    values.remove(Categories.ACCOUNT_TYPE);

    return values;
}
 
Example 6
Source File: ChromeBrowserProvider.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private long addBookmark(ContentValues values) {
    String url = values.getAsString(Browser.BookmarkColumns.URL);
    String title = values.getAsString(Browser.BookmarkColumns.TITLE);
    boolean isFolder = false;
    if (values.containsKey(BOOKMARK_IS_FOLDER_PARAM)) {
        isFolder = values.getAsBoolean(BOOKMARK_IS_FOLDER_PARAM);
    }
    long parentId = INVALID_BOOKMARK_ID;
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    long id = nativeAddBookmark(mNativeChromeBrowserProvider, url, title, isFolder, parentId);
    if (id == INVALID_BOOKMARK_ID) return id;

    if (isFolder) {
        updateLastModifiedBookmarkFolder(id);
    } else {
        updateLastModifiedBookmarkFolder(parentId);
    }
    return id;
}
 
Example 7
Source File: CategoryHandler.java    From opentasks-provider with Apache License 2.0 6 votes vote down vote up
/**
 * Check if a category with matching {@link ContentValues} exists and returns the existing category or creates a new category in the database.
 * 
 * @param db
 *            The {@link SQLiteDatabase}.
 * @param values
 *            The {@link ContentValues} of the category.
 * @return The {@link ContentValues} of the existing or new category.
 */
private ContentValues getOrInsertCategory(SQLiteDatabase db, ContentValues values)
{
	if (values.getAsBoolean(IS_NEW_CATEGORY))
	{
		// insert new category in category table
		ContentValues newCategoryValues = new ContentValues(4);
		newCategoryValues.put(Categories.ACCOUNT_NAME, values.getAsString(Categories.ACCOUNT_NAME));
		newCategoryValues.put(Categories.ACCOUNT_TYPE, values.getAsString(Categories.ACCOUNT_TYPE));
		newCategoryValues.put(Categories.NAME, values.getAsString(Category.CATEGORY_NAME));
		newCategoryValues.put(Categories.COLOR, values.getAsInteger(Category.CATEGORY_COLOR));

		long categoryID = db.insert(Tables.CATEGORIES, "", newCategoryValues);
		values.put(Category.CATEGORY_ID, categoryID);
	}

	// remove redundant values
	values.remove(IS_NEW_CATEGORY);
	values.remove(Categories.ACCOUNT_NAME);
	values.remove(Categories.ACCOUNT_TYPE);

	return values;
}
 
Example 8
Source File: SipMessage.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
public final void createFromContentValue(ContentValues args) {
    Integer tmp_i;
    String tmp_s;
    Long tmp_l;
    Boolean tmp_b;
    
    tmp_s = args.getAsString(FIELD_FROM);
    if(tmp_s != null) {
        from = tmp_s;
    }
    tmp_s = args.getAsString(FIELD_TO);
    if(tmp_s != null) {
        to = tmp_s;
    }
    tmp_s = args.getAsString(FIELD_CONTACT);
    if(tmp_s != null) {
        contact = tmp_s;
    }
    tmp_s = args.getAsString(FIELD_BODY);
    if(tmp_s != null) {
        body = tmp_s;
    }
    tmp_s = args.getAsString(FIELD_MIME_TYPE);
    if(tmp_s != null) {
        mimeType = tmp_s;
    }
    tmp_l = args.getAsLong(FIELD_DATE);
    if(tmp_l != null) {
        date = tmp_l;
    }
    tmp_i = args.getAsInteger(FIELD_TYPE);
    if(tmp_i != null) {
        type = tmp_i;
    }
    tmp_i = args.getAsInteger(FIELD_STATUS);
    if(tmp_i != null) {
        status = tmp_i;
    }
    tmp_b = args.getAsBoolean(FIELD_READ);
    if(tmp_b != null) {
        read = tmp_b;
    }

    tmp_s = args.getAsString(FIELD_FROM_FULL);
    if(tmp_s != null) {
        fullFrom = tmp_s;
    }
}
 
Example 9
Source File: SipProfileState.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
/** 
    * Fill account state object from content values.
    * @param args content values to wrap.
    */
public final void createFromContentValue(ContentValues args) {
	Integer tmp_i;
	String tmp_s;
	Boolean tmp_b;
	
	tmp_i = args.getAsInteger(ACCOUNT_ID);
	if(tmp_i != null) {
		databaseId = tmp_i;
	}
	tmp_i = args.getAsInteger(PJSUA_ID);
	if(tmp_i != null) {
		pjsuaId = tmp_i;
	}
	tmp_s = args.getAsString(WIZARD);
	if(tmp_s != null) {
		wizard = tmp_s;
	}
	tmp_b = args.getAsBoolean(ACTIVE);
	if(tmp_b != null) {
		active = tmp_b;
	}
	tmp_i = args.getAsInteger(STATUS_CODE);
	if(tmp_i != null) {
		statusCode = tmp_i;
	}
	tmp_s = args.getAsString(STATUS_TEXT);
	if(tmp_s != null) {
		statusText = tmp_s;
	}
	tmp_i = args.getAsInteger(ADDED_STATUS);
	if(tmp_i != null) {
		addedStatus = tmp_i;
	}
	tmp_i = args.getAsInteger(EXPIRES);
	if(tmp_i != null) {
		expires = tmp_i;
	}
	tmp_s = args.getAsString(DISPLAY_NAME);
	if(tmp_s != null) {
		displayName = tmp_s;
	}
	tmp_s = args.getAsString(REG_URI);
	if(tmp_s != null) {
		regUri = tmp_s;
	}
	tmp_i = args.getAsInteger(PRIORITY);
	if(tmp_i != null) {
		priority = tmp_i;
	}
	
}
 
Example 10
Source File: Imps.java    From Zom-Android-XMPP with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Convenience function for retrieving a single settings value as a
 * boolean.
 *
 * @param name The name of the setting to retrieve.
 * @param def Value to return if the setting is not defined.
 * @return The setting's current value, or 'def' if it is not
 *         defined.
 */
private boolean getBoolean(String name, boolean def) {
    ContentValues values = getValues(name);
    return values != null ? values.getAsBoolean(VALUE) : def;
}