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


Java ContentValues.getAsDouble方法代码示例

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


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

示例1: validateExpenseAndUpdate

import android.content.ContentValues; //导入方法依赖的package包/类
private int validateExpenseAndUpdate(final Uri uri, final ContentValues contentValues, long id) {

        if (contentValues.containsKey(ExpenseEntry.COLUMN_INFO)) {
            String info = contentValues.getAsString(ExpenseEntry.COLUMN_INFO).trim();
            if (info.isEmpty()) {
                throw new IllegalArgumentException("Expense info must be set.");
            }
        }

        if (contentValues.containsKey(ExpenseEntry.COLUMN_PRICE)) {
            Double price = contentValues.getAsDouble(ExpenseEntry.COLUMN_PRICE);
            if (price == null || price < 0) {
                throw new IllegalArgumentException("Wrong price " + price);
            }
        }

        if (contentValues.containsKey(ExpenseEntry.COLUMN_VEHICLE)) {
            Long vehicleId = contentValues.getAsLong(ExpenseEntry.COLUMN_VEHICLE);
            String selectionVehicle = VehicleEntry._ID + "=?";
            String[] selectionVehicleArgs = new String[] { String.valueOf(vehicleId) };
            Cursor cursor = mDbHelper.getReadableDatabase().query(VehicleEntry.TABLE_NAME, FuelUpContract.ALL_COLUMNS_VEHICLES, selectionVehicle, selectionVehicleArgs, null, null, null);
            if (cursor == null || cursor.getCount() != 1) {
                if (cursor != null)
                    cursor.close();
                throw new IllegalArgumentException("Vehicle with id=" + vehicleId + " does not exist.");
            }
            cursor.close();
        }

        final String selection = ExpenseEntry._ID + "=?";
        final String[] idArgument = new String[] { String.valueOf(id) };

        getContext().getContentResolver().notifyChange(uri, null);
        return mDbHelper.getWritableDatabase().update(
                ExpenseEntry.TABLE_NAME, contentValues, selection, idArgument);
    }
 
开发者ID:piskula,项目名称:FuelUp,代码行数:37,代码来源:VehicleProvider.java

示例2: validateExpenseAndInsert

import android.content.ContentValues; //导入方法依赖的package包/类
private Uri validateExpenseAndInsert(Uri uri, ContentValues contentValues) {

        String info = contentValues.getAsString(ExpenseEntry.COLUMN_INFO).trim();
        if (info.isEmpty()) {
            throw new IllegalArgumentException("Expense info must be set.");
        }

        Double price = contentValues.getAsDouble(ExpenseEntry.COLUMN_PRICE);
        if (price == null || price < 0) {
            throw new IllegalArgumentException("Wrong price " + price);
        }

        Long vehicleId = contentValues.getAsLong(ExpenseEntry.COLUMN_VEHICLE);
        String selection = VehicleEntry._ID + "=?";
        String[] selectionArgs = new String[] { String.valueOf(vehicleId) };
        Cursor cursor = mDbHelper.getReadableDatabase().query(VehicleEntry.TABLE_NAME, FuelUpContract.ALL_COLUMNS_VEHICLES, selection, selectionArgs, null, null, null);
        if (cursor == null || cursor.getCount() != 1) {
            if (cursor != null)
                cursor.close();
            throw new IllegalArgumentException("Vehicle with id=" + vehicleId + " does not exist.");
        }
        cursor.close();

        SQLiteDatabase database = mDbHelper.getWritableDatabase();
        long id = database.insert(ExpenseEntry.TABLE_NAME, null, contentValues);

        if (id == -1) {
            Log.e(LOG_TAG, "Failed to insert row for " + uri);
            return null;
        }

        getContext().getContentResolver().notifyChange(uri, null);
        return ContentUris.withAppendedId(uri, id);
    }
 
开发者ID:piskula,项目名称:FuelUp,代码行数:35,代码来源:VehicleProvider.java

示例3: setContent

import android.content.ContentValues; //导入方法依赖的package包/类
public void setContent(ContentValues cv) {
    id = cv.getAsString("ID");
    name = cv.getAsString("Name");
    lat = cv.getAsDouble("Lat");
    lon = cv.getAsDouble("Lon");
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:7,代码来源:Cinema.java


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