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


Java Cursor.getFloat方法代码示例

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


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

示例1: readEntity

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public SimpleEntityNotNull readEntity(Cursor cursor, int offset) {
    SimpleEntityNotNull entity = new SimpleEntityNotNull( //
        cursor.getLong(offset + 0), // id
        cursor.getShort(offset + 1) != 0, // simpleBoolean
        (byte) cursor.getShort(offset + 2), // simpleByte
        cursor.getShort(offset + 3), // simpleShort
        cursor.getInt(offset + 4), // simpleInt
        cursor.getLong(offset + 5), // simpleLong
        cursor.getFloat(offset + 6), // simpleFloat
        cursor.getDouble(offset + 7), // simpleDouble
        cursor.getString(offset + 8), // simpleString
        cursor.getBlob(offset + 9) // simpleByteArray
    );
    return entity;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SimpleEntityNotNullDao.java

示例2: getObject

import android.database.Cursor; //导入方法依赖的package包/类
static Object getObject(Cursor cursor, int columnIndex) throws Exception
{
    int type = getType(cursor, columnIndex);
    Object value;
    switch (type)
    {
        case Cursor.FIELD_TYPE_BLOB:
            value = cursor.getBlob(columnIndex);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = cursor.getFloat(columnIndex);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = cursor.getLong(columnIndex);
            break;
        case Cursor.FIELD_TYPE_NULL:
            value = null;
            break;
        case Cursor.FIELD_TYPE_STRING:
            value = cursor.getString(columnIndex);
            break;
        default:
            value = cursor.getString(columnIndex);
    }
    return value;
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:27,代码来源:TypeUtil.java

示例3: query

import android.database.Cursor; //导入方法依赖的package包/类
/**
 * 查询所有数据
 * @return
 */
public ArrayList<Location> query(){

        Cursor cursor=db.rawQuery("select * from location ",null);
    ArrayList<Location> list=new ArrayList<>();
    if (cursor.moveToFirst()) {
        do {
            Location location =new Location();
            location.time=cursor.getString(1);
            location.lat=cursor.getFloat(2);
            location.lng=cursor.getFloat(3);
            location.address=cursor.getString(4);
            location.userid=cursor.getString(5);

            list.add(location);
        }while(cursor.moveToNext());

    }
    cursor.close();
    return list;

}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:26,代码来源:MapDatebaseManager.java

示例4: querylastLocation

import android.database.Cursor; //导入方法依赖的package包/类
/**
 * 查询最后几条数据
 * @return
 */
public ArrayList<Location> querylastLocation(int n){

    Cursor cursor=db.rawQuery("select * from location order by id desc limit "+n,null);
    ArrayList<Location> list=new ArrayList<>();
    if (cursor.moveToFirst()) {


        do {
            Location location =new Location();
            location.time=cursor.getString(1);
            location.lat=cursor.getFloat(2);
            location.lng=cursor.getFloat(3);
            location.address=cursor.getString(4);
            location.userid=cursor.getString(5);

            list.add(location);
        }while(cursor.moveToNext());

    }
    cursor.close();
    return list;


}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:29,代码来源:MapDatebaseManager.java

示例5: getBooks

import android.database.Cursor; //导入方法依赖的package包/类
protected List<Book> getBooks(String[] columns, String selection, String[] selectionArgs,
		String groupBy, String having, String orderBy, String limit) {
	List<Book> books = new ArrayList<Book>();
	Cursor cursor = Connector.getDatabase().query(getTableName(Book.class), columns, selection, selectionArgs,
			groupBy, having, orderBy, limit);
	if (cursor.moveToFirst()) {
		do {
			long id = cursor.getLong(cursor.getColumnIndexOrThrow("id"));
			String bookName = cursor.getString(cursor.getColumnIndexOrThrow("bookname"));
			int pages = cursor.getInt(cursor.getColumnIndexOrThrow("pages"));
			double price = cursor.getDouble(cursor.getColumnIndexOrThrow("price"));
			char level = cursor.getString(cursor.getColumnIndexOrThrow("level")).charAt(0);
			short isbn = cursor.getShort(cursor.getColumnIndexOrThrow("isbn"));
			float area = cursor.getFloat(cursor.getColumnIndexOrThrow("area"));
			boolean isPublished = cursor.getInt(cursor.getColumnIndexOrThrow("ispublished")) == 1;
			Book book = new Book();
			book.setId(id);
			book.setBookName(bookName);
			book.setPages(pages);
			book.setPrice(price);
			book.setLevel(level);
			book.setIsbn(isbn);
			book.setArea(area);
			book.setPublished(isPublished);
			books.add(book);
		} while (cursor.moveToNext());
	}
	cursor.close();
	return books;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:LitePalTestCase.java

示例6: searchAll

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public List<Object> searchAll() {
    List<Object> pedidos = new ArrayList<>();

    StringBuilder sql = new StringBuilder();

    sql.append("SELECT  CODIGO, TITULO, DATAENTREGA, DESCRICAO, VALOR, PAGO, CODCLIENTE ");
    sql.append("    FROM PEDIDO");

    Cursor resultado = connection.rawQuery(sql.toString(), null);

    if(resultado.getCount() > 0){
        resultado.moveToFirst();

        do{
            Pedido pedido = new Pedido();

            pedido.codigo = resultado.getInt(resultado.getColumnIndexOrThrow("CODIGO"));
            pedido.titulo = resultado.getString(resultado.getColumnIndexOrThrow("TITULO"));
            pedido.setDataEntrega(resultado.getString(resultado.getColumnIndexOrThrow("DATAENTREGA")));
            pedido.descricao = resultado.getString(resultado.getColumnIndexOrThrow("DESCRICAO"));
            pedido.valor = resultado.getFloat(resultado.getColumnIndexOrThrow("VALOR"));
            pedido.pago = resultado.getInt(resultado.getColumnIndexOrThrow("PAGO"));
            pedido.codCliente = resultado.getInt(resultado.getColumnIndexOrThrow("CODCLIENTE"));

            pedidos.add(pedido);
        }
        while (resultado.moveToNext());
    }

    resultado.close();

    return pedidos;
}
 
开发者ID:victorvgc,项目名称:natumassas-app,代码行数:35,代码来源:PedidoRepositorio.java

示例7: getSum

import android.database.Cursor; //导入方法依赖的package包/类
public double getSum(long folderId, long roadId, long measurementId, String column, String table) {
    double sum = 0;
    try {
        String queryStr = getQueryStr(folderId, roadId, measurementId);
        String calcDistanceQuery = "SELECT SUM(" + column
                + ") FROM " + table
                + " WHERE " + queryStr;
        final Cursor cursor = getDatabase().rawQuery(calcDistanceQuery, null);
        cursor.moveToFirst();
        sum = cursor.getFloat(0);
    } catch (Exception e) {
        Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
    }
    return sum;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:16,代码来源:BaseDAO.java

示例8: getPreferenceFloatValue

import android.database.Cursor; //导入方法依赖的package包/类
/**
 * Helper method to retrieve a csipsimple float config value
 * 
 * @param ctxt The context of your app
 * @param key the key for the setting you want to get
 * @param defaultValue the value you want to return if nothing found
 * @return the preference value
 */
public static Float getPreferenceFloatValue(Context ctxt, String key, Float defaultValue) {
    Float value = defaultValue;
    Uri uri = getPrefUriForKey(key);
    Cursor c = ctxt.getContentResolver().query(uri, null, Float.class.getName(), null, null);
    if (c != null) {
        c.moveToFirst();
        Float fValue = c.getFloat(1);
        if (fValue != null) {
            value = fValue;
        }
        c.close();
    }
    return value;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:23,代码来源:SipConfigManager.java

示例9: cursor2Map

import android.database.Cursor; //导入方法依赖的package包/类
public static Map<String, Object> cursor2Map(Cursor cursor) {
    Map<String, Object> map = new HashMap<>();
    if (cursor != null && cursor.getColumnCount() > 0) {
        int count = cursor.getColumnCount();
        for (int i = 0; i < count; i++) {
            int type = cursor.getType(i);

            Object value = null;
            switch (type) {
                case Cursor.FIELD_TYPE_STRING:
                    value = cursor.getString(i);
                    break;
                case Cursor.FIELD_TYPE_INTEGER:
                    value = cursor.getInt(i);
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    value = cursor.getFloat(i);
                    break;
                case Cursor.FIELD_TYPE_NULL:
                    LogUtils.d("未知的参数类型,type:" + type);
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    LogUtils.d("未知的参数类型,type:" + type);
                    break;
            }
            if (value != null) {
                String name = cursor.getColumnName(i);
                map.put(name, value);
            }
        }
    }
    return map;
}
 
开发者ID:jessie345,项目名称:RetrofitAppArchitecture,代码行数:34,代码来源:Utils.java

示例10: copyColumns

import android.database.Cursor; //导入方法依赖的package包/类
private void copyColumns(Cursor cursor, MatrixCursor result, int count) {
	try {
		Object[] columns = new Object[count];
		for (int i = 0; i < count; i++)
			switch (cursor.getType(i)) {
			case Cursor.FIELD_TYPE_NULL:
				columns[i] = null;
				break;
			case Cursor.FIELD_TYPE_INTEGER:
				columns[i] = cursor.getInt(i);
				break;
			case Cursor.FIELD_TYPE_FLOAT:
				columns[i] = cursor.getFloat(i);
				break;
			case Cursor.FIELD_TYPE_STRING:
				columns[i] = cursor.getString(i);
				break;
			case Cursor.FIELD_TYPE_BLOB:
				columns[i] = cursor.getBlob(i);
				break;
			default:
				Util.log(this, Log.WARN, "Unknown cursor data type=" + cursor.getType(i));
			}
		result.addRow(columns);
	} catch (Throwable ex) {
		Util.bug(this, ex);
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:29,代码来源:XContentResolver.java

示例11: getFloatValue

import android.database.Cursor; //导入方法依赖的package包/类
private static float getFloatValue(Cursor cursor, float def) {
    if (cursor == null)
        return def;
    float value = def;
    if (cursor.moveToFirst()) {
        value = cursor.getFloat(0);
    }
    cursor.close();
    return value;
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:11,代码来源:MultiProcessPreference.java

示例12: getFieldValue

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public Float getFieldValue(final Cursor cursor, int index) {
    return cursor.isNull(index) ? null : cursor.getFloat(index);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:FloatColumnConverter.java

示例13: getRefuelsByTagChartData

import android.database.Cursor; //导入方法依赖的package包/类
public ArrayList<chartData> getRefuelsByTagChartData(String[] selectionArgs, boolean getValue) {
    ArrayList<chartData> retVal = new ArrayList<>();
    float totalValue = 0f;

    String sqlWhere = " WHERE " + sqlConcatTableColumn(TABLE_NAME_REFUEL, COL_NAME_REFUEL__CAR_ID) + " = ?";
    if(selectionArgs.length > 1 && !selectionArgs[1].equals("0"))
        sqlWhere = sqlWhere + " AND " + sqlConcatTableColumn(TABLE_NAME_REFUEL, COL_NAME_REFUEL__DATE) + " >= ?";
    else
        sqlWhere = sqlWhere + " AND '0' = ? ";

    if(selectionArgs.length > 2 && !selectionArgs[2].equals("0"))
        sqlWhere = sqlWhere + " AND " + sqlConcatTableColumn(TABLE_NAME_REFUEL, COL_NAME_REFUEL__DATE) + " <= ?";
    else
        sqlWhere = sqlWhere + " AND '0' = ? ";

    String selColName;
    if(getValue)
        selColName = COL_NAME_REFUEL__AMOUNT;
    else
        selColName = COL_NAME_REFUEL__QUANTITY;

    //get the sum for calculating the percent of each type
    String selectSql =
            " SELECT SUM(" + sqlConcatTableColumn(TABLE_NAME_REFUEL, selColName) + ") " +
            " FROM " + TABLE_NAME_REFUEL +
            sqlWhere;

    Cursor c = mDb.rawQuery(selectSql, selectionArgs);
    if (c.moveToFirst()) {
        totalValue = c.getFloat(0);
    }
    c.close();
    if (totalValue == 0f)
        return retVal; //no entries

    selectSql =
            " SELECT SUM(" + sqlConcatTableColumn(TABLE_NAME_REFUEL, selColName) + "), " +
                    "SUM(" + sqlConcatTableColumn(TABLE_NAME_REFUEL, selColName) + ") * 100 / " + totalValue + ", " + //in percent
                    "COALESCE( " + sqlConcatTableColumn(TABLE_NAME_TAG, COL_NAME_GEN_NAME) + ", 'N/A')" +
            " FROM " + TABLE_NAME_REFUEL +
            " LEFT OUTER JOIN " + TABLE_NAME_TAG + " ON " +
                    sqlConcatTableColumn(TABLE_NAME_REFUEL, COL_NAME_REFUEL__TAG_ID) +
                    "=" + sqlConcatTableColumn(TABLE_NAME_TAG, COL_NAME_GEN_ROWID) +
            sqlWhere +
            " GROUP BY COALESCE( " + sqlConcatTableColumn(TABLE_NAME_TAG, COL_NAME_GEN_NAME) + ", 'N/A')" +
            " ORDER BY 1 DESC";
    c = mDb.rawQuery(selectSql, selectionArgs);
    while (c.moveToNext()) {
        chartData cd = new chartData();
        cd.value = c.getFloat(0);
        cd.value2 = c.getFloat(1);
        cd.totalValue = totalValue;
        cd.label = c.getString(2);
        retVal.add(cd);
    }
    c.close();
    return retVal;
}
 
开发者ID:mkeresztes,项目名称:AndiCar,代码行数:59,代码来源:DBReportAdapter.java

示例14: GetPointX

import android.database.Cursor; //导入方法依赖的package包/类
public float GetPointX(int level, int n){
	Cursor cu = mydb.query("Pointsx", null, "ID="+level, null, null, null, null);
	cu.moveToPosition(0);
	float point = cu.getFloat(n+1);
	return point;
}
 
开发者ID:AmulaySoftGroup,项目名称:TaBeTa,代码行数:7,代码来源:InternalDB.java

示例15: selectWithCursor

import android.database.Cursor; //导入方法依赖的package包/类
public User selectWithCursor(Cursor cursor) {
    if (cursor == null) {
        return null;
    }
    String token = cursor.getString(cursor.getColumnIndex("token"));
    String user_key = cursor.getString(cursor.getColumnIndex("user_key"));
    String cellphone = cursor.getString(cursor.getColumnIndex("cellphone"));
    String user_name = cursor.getString(cursor.getColumnIndex(USER_NAME));
    String sex_type = cursor.getString(cursor.getColumnIndex("sex_type"));
    String birthday = cursor.getString(cursor.getColumnIndex("birthday"));
    float height = cursor.getFloat(cursor.getColumnIndex("height"));
    float begin_weight = cursor.getFloat(cursor.getColumnIndex(BEGIN_WEIGHT));
    float target_weight = cursor.getFloat(cursor.getColumnIndex("target_weight"));
    String target_date = cursor.getString(cursor.getColumnIndex("target_date"));
    int target_calory = cursor.getInt(cursor.getColumnIndex("target_calory"));
    String updated_at = cursor.getString(cursor.getColumnIndex("updated_at"));
    String avatar = cursor.getString(cursor.getColumnIndex(AVATAR));
    String description = cursor.getString(cursor.getColumnIndex("description"));
    float latest_weight = cursor.getFloat(cursor.getColumnIndex("latest_weight"));
    String latest_weight_at = cursor.getString(cursor.getColumnIndex(LATEST_WEIGHT_AT));
    float latest_waist = cursor.getFloat(cursor.getColumnIndex(LATEST_WAIST));
    String latest_waist_at = cursor.getString(cursor.getColumnIndex(LATEST_WAIST_AT));
    int post_count = cursor.getInt(cursor.getColumnIndex(POST_COUNT));
    int envious_count = cursor.getInt(cursor.getColumnIndex(ENVIOUS_COUNT));
    int following_count = cursor.getInt(cursor.getColumnIndex(FOLLOWING_COUNT));
    int follower_count = cursor.getInt(cursor.getColumnIndex(FOLLOWER_COUNT));
    int badges_count = cursor.getInt(cursor.getColumnIndex(BADGES_COUNT));
    String sport_condition = cursor.getString(cursor.getColumnIndex(SPORT_CONDITION));
    String diseaes = cursor.getString(cursor.getColumnIndex(DISEASES));
    int need_test = cursor.getInt(cursor.getColumnIndex(NEED_TEST));
    String begin_date = cursor.getString(cursor.getColumnIndex("begin_date"));
    cursor.close();
    return new Builder().setToken(token).setUserKey(user_key).setCellPhone(cellphone)
            .setUserName(user_name).setSexType(sex_type).setBirthDay(birthday).setHeight
                    (height).setBeginWeight(begin_weight).setTargetWeight(target_weight)
            .setTargetDate(target_date).setTargetCalory(target_calory).setUpdateAt
                    (updated_at).setAvatarUrl(avatar).setDescription(description)
            .setLatestWeight(latest_weight).setLatestWeightAt(latest_weight_at)
            .setLatestWaist(Float.valueOf(latest_waist)).setLatestWaistAt(latest_waist_at)
            .setPostCount(post_count).setEnviousCount(envious_count).setFollowingCount(following_count).setFollowerCount(follower_count).setBadgesCount(badges_count).setSportCondition(sport_condition).setDiseases(diseaes).setNeedTest(need_test).setBeginDate(begin_date).create();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:42,代码来源:UserDao.java


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