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

The following examples show how to use android.content.ContentValues#getAsByteArray() . 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 delion with Apache License 2.0 5 votes vote down vote up
static BookmarkRow fromContentValues(ContentValues values) {
    BookmarkRow row = new BookmarkRow();
    if (values.containsKey(BookmarkColumns.URL)) {
        row.mUrl = values.getAsString(BookmarkColumns.URL);
    }
    if (values.containsKey(BookmarkColumns.BOOKMARK)) {
        row.mIsBookmark = values.getAsInteger(BookmarkColumns.BOOKMARK) != 0;
    }
    if (values.containsKey(BookmarkColumns.CREATED)) {
        row.mCreated = values.getAsLong(BookmarkColumns.CREATED);
    }
    if (values.containsKey(BookmarkColumns.DATE)) {
        row.mDate = values.getAsLong(BookmarkColumns.DATE);
    }
    if (values.containsKey(BookmarkColumns.FAVICON)) {
        row.mFavicon = values.getAsByteArray(BookmarkColumns.FAVICON);
        // We need to know that the caller set the favicon column.
        if (row.mFavicon == null) {
            row.mFavicon = new byte[0];
        }
    }
    if (values.containsKey(BookmarkColumns.TITLE)) {
        row.mTitle = values.getAsString(BookmarkColumns.TITLE);
    }
    if (values.containsKey(BookmarkColumns.VISITS)) {
        row.mVisits = values.getAsInteger(BookmarkColumns.VISITS);
    }
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        row.mParentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    return row;
}
 
Example 2
Source File: ChromeBrowserProvider.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
static BookmarkRow fromContentValues(ContentValues values) {
    BookmarkRow row = new BookmarkRow();
    if (values.containsKey(BookmarkColumns.URL)) {
        row.mUrl = values.getAsString(BookmarkColumns.URL);
    }
    if (values.containsKey(BookmarkColumns.BOOKMARK)) {
        row.mIsBookmark = values.getAsInteger(BookmarkColumns.BOOKMARK) != 0;
    }
    if (values.containsKey(BookmarkColumns.CREATED)) {
        row.mCreated = values.getAsLong(BookmarkColumns.CREATED);
    }
    if (values.containsKey(BookmarkColumns.DATE)) {
        row.mDate = values.getAsLong(BookmarkColumns.DATE);
    }
    if (values.containsKey(BookmarkColumns.FAVICON)) {
        row.mFavicon = values.getAsByteArray(BookmarkColumns.FAVICON);
        // We need to know that the caller set the favicon column.
        if (row.mFavicon == null) {
            row.mFavicon = new byte[0];
        }
    }
    if (values.containsKey(BookmarkColumns.TITLE)) {
        row.mTitle = values.getAsString(BookmarkColumns.TITLE);
    }
    if (values.containsKey(BookmarkColumns.VISITS)) {
        row.mVisits = values.getAsInteger(BookmarkColumns.VISITS);
    }
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        row.mParentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    return row;
}
 
Example 3
Source File: ChromeBrowserProvider.java    From 365browser with Apache License 2.0 5 votes vote down vote up
static BookmarkRow fromContentValues(ContentValues values) {
    BookmarkRow row = new BookmarkRow();
    if (values.containsKey(BookmarkColumns.URL)) {
        row.mUrl = values.getAsString(BookmarkColumns.URL);
    }
    if (values.containsKey(BookmarkColumns.BOOKMARK)) {
        row.mIsBookmark = values.getAsInteger(BookmarkColumns.BOOKMARK) != 0;
    }
    if (values.containsKey(BookmarkColumns.CREATED)) {
        row.mCreated = values.getAsLong(BookmarkColumns.CREATED);
    }
    if (values.containsKey(BookmarkColumns.DATE)) {
        row.mDate = values.getAsLong(BookmarkColumns.DATE);
    }
    if (values.containsKey(BookmarkColumns.FAVICON)) {
        row.mFavicon = values.getAsByteArray(BookmarkColumns.FAVICON);
        // We need to know that the caller set the favicon column.
        if (row.mFavicon == null) {
            row.mFavicon = new byte[0];
        }
    }
    if (values.containsKey(BookmarkColumns.TITLE)) {
        row.mTitle = values.getAsString(BookmarkColumns.TITLE);
    }
    if (values.containsKey(BookmarkColumns.VISITS)) {
        row.mVisits = values.getAsInteger(BookmarkColumns.VISITS);
    }
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        row.mParentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    return row;
}
 
Example 4
Source File: DataProvider.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
private void populateFields(MapObject mapObject, ContentValues values) {
    double latitude = 0.0, longitude = 0.0;

    String key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_NAME_COLUMN];
    if (values.containsKey(key))
        mapObject.name = values.getAsString(key);

    key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_DESCRIPTION_COLUMN];
    if (values.containsKey(key))
        mapObject.description = values.getAsString(key);

    key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_LATITUDE_COLUMN];
    if (values.containsKey(key))
        latitude = values.getAsDouble(key);

    key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_LONGITUDE_COLUMN];
    if (values.containsKey(key))
        longitude = values.getAsDouble(key);

    key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_MARKER_COLUMN];
    if (values.containsKey(key))
        mapObject.marker = values.getAsString(key);

    key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_COLOR_COLUMN];
    if (values.containsKey(key)) {
        mapObject.textColor = values.getAsInteger(key);
        mapObject.style.color = mapObject.textColor;
    }

    key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_BITMAP_COLUMN];
    if (values.containsKey(key)) {
        byte[] bytes = values.getAsByteArray(key);
        if (bytes != null)
            mapObject.setBitmap(BitmapFactory.decodeByteArray(bytes, 0, bytes.length));
    }
    if (mapObject.coordinates.getLatitude() != latitude || mapObject.coordinates.getLongitude() != longitude) {
        mapObject.setCoordinates(latitude, longitude);
    }
}
 
Example 5
Source File: ChromeBrowserProvider.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static BookmarkRow fromContentValues(ContentValues values) {
    BookmarkRow row = new BookmarkRow();
    if (values.containsKey(BookmarkColumns.URL)) {
        row.url = values.getAsString(BookmarkColumns.URL);
    }
    if (values.containsKey(BookmarkColumns.BOOKMARK)) {
        row.isBookmark = values.getAsInteger(BookmarkColumns.BOOKMARK) != 0;
    }
    if (values.containsKey(BookmarkColumns.CREATED)) {
        row.created = values.getAsLong(BookmarkColumns.CREATED);
    }
    if (values.containsKey(BookmarkColumns.DATE)) {
        row.date = values.getAsLong(BookmarkColumns.DATE);
    }
    if (values.containsKey(BookmarkColumns.FAVICON)) {
        row.favicon = values.getAsByteArray(BookmarkColumns.FAVICON);
        // We need to know that the caller set the favicon column.
        if (row.favicon == null) {
            row.favicon = new byte[0];
        }
    }
    if (values.containsKey(BookmarkColumns.TITLE)) {
        row.title = values.getAsString(BookmarkColumns.TITLE);
    }
    if (values.containsKey(BookmarkColumns.VISITS)) {
        row.visits = values.getAsInteger(BookmarkColumns.VISITS);
    }
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        row.parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    return row;
}
 
Example 6
Source File: ChromeBrowserProvider.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static BookmarkRow fromContentValues(ContentValues values) {
    BookmarkRow row = new BookmarkRow();
    if (values.containsKey(BookmarkColumns.URL)) {
        row.url = values.getAsString(BookmarkColumns.URL);
    }
    if (values.containsKey(BookmarkColumns.BOOKMARK)) {
        row.isBookmark = values.getAsInteger(BookmarkColumns.BOOKMARK) != 0;
    }
    if (values.containsKey(BookmarkColumns.CREATED)) {
        row.created = values.getAsLong(BookmarkColumns.CREATED);
    }
    if (values.containsKey(BookmarkColumns.DATE)) {
        row.date = values.getAsLong(BookmarkColumns.DATE);
    }
    if (values.containsKey(BookmarkColumns.FAVICON)) {
        row.favicon = values.getAsByteArray(BookmarkColumns.FAVICON);
        // We need to know that the caller set the favicon column.
        if (row.favicon == null) {
            row.favicon = new byte[0];
        }
    }
    if (values.containsKey(BookmarkColumns.TITLE)) {
        row.title = values.getAsString(BookmarkColumns.TITLE);
    }
    if (values.containsKey(BookmarkColumns.VISITS)) {
        row.visits = values.getAsInteger(BookmarkColumns.VISITS);
    }
    if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
        row.parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
    }
    return row;
}
 
Example 7
Source File: BinaryFieldAdapter.java    From opentasks with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] getFrom(ContentValues values)
{
    return values.getAsByteArray(mFieldName);
}
 
Example 8
Source File: DataProvider.java    From Androzic with GNU General Public License v3.0 4 votes vote down vote up
private void populateFields(MapObject mo, ContentValues values)
{
	String key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_NAME_COLUMN];
	if (values.containsKey(key))
		mo.name = values.getAsString(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_DESCRIPTION_COLUMN];
	if (values.containsKey(key))
		mo.description = values.getAsString(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_LATITUDE_COLUMN];
	if (values.containsKey(key))
		mo.latitude = values.getAsDouble(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_LONGITUDE_COLUMN];
	if (values.containsKey(key))
		mo.longitude = values.getAsDouble(key);
	
	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_IMAGE_COLUMN];
	if (values.containsKey(key))
		mo.image = values.getAsString(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_MARKER_COLUMN];
	if (values.containsKey(key))
		mo.marker = values.getAsString(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_TEXTCOLOR_COLUMN];
	if (values.containsKey(key))
		mo.textcolor = values.getAsInteger(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_BACKCOLOR_COLUMN];
	if (values.containsKey(key))
		mo.backcolor = values.getAsInteger(key);

	key = DataContract.MAPOBJECT_COLUMNS[DataContract.MAPOBJECT_BITMAP_COLUMN];
	if (values.containsKey(key))
	{
		byte[] bytes = values.getAsByteArray(key);
		if (mo.bitmap != null)
		{
			mo.bitmap.recycle();
			mo.bitmap = null;
		}
		if (bytes != null)
			mo.bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
	}
}
 
Example 9
Source File: BinaryFieldAdapter.java    From opentasks-provider with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] getFrom(ContentValues values)
{
	return values.getAsByteArray(mFieldName);
}