本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例12: getFieldValue
import android.database.Cursor; //导入方法依赖的package包/类
@Override
public Float getFieldValue(final Cursor cursor, int index) {
return cursor.isNull(index) ? null : cursor.getFloat(index);
}
示例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;
}
示例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;
}
示例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();
}