Java Code Examples for android.database.Cursor#FIELD_TYPE_BLOB

The following examples show how to use android.database.Cursor#FIELD_TYPE_BLOB . These examples are extracted from open source projects. 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
public static void read(Cursor cursor) {
    int count = cursor.getCount();
    if (count > 0) {
        cursor.moveToFirst();
        int type = cursor.getType(0);
        switch (type) {
            case Cursor.FIELD_TYPE_BLOB:
            case Cursor.FIELD_TYPE_NULL: {
                break;
            }
            case Cursor.FIELD_TYPE_INTEGER:
            case Cursor.FIELD_TYPE_FLOAT:
            case Cursor.FIELD_TYPE_STRING:
            default: {
                cursor.getString(0);
                break;
            }
        }
    }
}
 
Example 2
Source Project: android-orm   File: DBProxy.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 封装内容到Map对象
 *
 * @param cursor
 * @param columnName
 * @param map
 */
private void putMapKeyValue(Cursor cursor, String columnName, Map<String, Object> map) {
    int columnIndex = cursor.getColumnIndex(columnName);
    int type = cursor.getType(columnIndex);
    switch (type) {
        case Cursor.FIELD_TYPE_INTEGER:
            map.put(columnName, cursor.getLong(columnIndex));
            break;
        case Cursor.FIELD_TYPE_STRING:
            map.put(columnName, cursor.getString(columnIndex));
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            map.put(columnName, cursor.getFloat(columnIndex));
            break;
        case Cursor.FIELD_TYPE_BLOB:
            map.put(columnName, cursor.getBlob(columnIndex));
            break;
        case Cursor.FIELD_TYPE_NULL:
            map.put(columnName, cursor.getString(columnIndex));
            break;
        default:
            break;
    }
}
 
Example 3
Source Project: DoraemonKit   File: DatabaseUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static String[][] queryAll(SQLiteDatabase database, String tableName) {
    String[] strings = queryTableColumnName(database, tableName);
    Cursor cursor = database.query(tableName, null, null, null, null, null, null);
    int rowCount = cursor.getCount();
    String[][] words = new String[strings.length][rowCount];
    for (int y = 0; y < rowCount; y++) {
        if (cursor.moveToNext()) {
            for (int x = 0; x < strings.length; x++) {
                if (cursor.getType(x) == Cursor.FIELD_TYPE_BLOB) {
                    words[x][y] = new String(cursor.getBlob(x));
                } else {
                    words[x][y] = cursor.getString(x);
                }
            }
        }
    }
    cursor.close();
    return words;
}
 
Example 4
public static Object cursorValue(String column, Cursor cr) {
    Object value = false;
    int index = cr.getColumnIndex(column);
    switch (cr.getType(index)) {
        case Cursor.FIELD_TYPE_NULL:
            value = false;
            break;
        case Cursor.FIELD_TYPE_STRING:
            value = cr.getString(index);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = cr.getInt(index);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = cr.getFloat(index);
            break;
        case Cursor.FIELD_TYPE_BLOB:
            value = cr.getBlob(index);
            break;
    }
    return value;
}
 
Example 5
Source Project: wellsql   File: MapperAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public T convert(Cursor item) {
    Map<String, Object> map = new HashMap<>();
    for (String column : item.getColumnNames()) {
        int columnIndex = item.getColumnIndex(column);
        switch (item.getType(columnIndex)) {
            case Cursor.FIELD_TYPE_INTEGER:
                map.put(column, item.getLong(columnIndex));
                break;
            case Cursor.FIELD_TYPE_STRING:
                map.put(column, item.getString(columnIndex));
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                map.put(column, item.getFloat(columnIndex));
                break;
            case Cursor.FIELD_TYPE_BLOB:
                map.put(column, item.getBlob(columnIndex));
                break;
        }
    }
    return mMapper.convert(map);
}
 
Example 6
public static Object cursorValue(String column, Cursor cr) {
    Object value = false;
    int index = cr.getColumnIndex(column);
    switch (cr.getType(index)) {
        case Cursor.FIELD_TYPE_NULL:
            value = false;
            break;
        case Cursor.FIELD_TYPE_STRING:
            value = cr.getString(index);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = cr.getInt(index);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = cr.getFloat(index);
            break;
        case Cursor.FIELD_TYPE_BLOB:
            value = cr.getBlob(index);
            break;
    }
    return value;
}
 
Example 7
@Override
public byte convertLocalTypeToGSN(int jdbcType, int precision) {
	switch (jdbcType) {
		case Cursor.FIELD_TYPE_INTEGER:
			return DataTypes.INTEGER;
		case Cursor.FIELD_TYPE_STRING:
			return DataTypes.VARCHAR;
		case Cursor.FIELD_TYPE_FLOAT:
			return DataTypes.DOUBLE;
		case Cursor.FIELD_TYPE_BLOB:
			return DataTypes.BINARY;
		default:
			Log.e(TAG, "convertLocalTypeToGSN: The type can't be converted to GSN form : " + jdbcType);
			break;
	}
	return -100;
}
 
Example 8
public static int getType(Cursor cursor, int i) {
    SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
    CursorWindow cursorWindow = sqLiteCursor.getWindow();
    int pos = cursor.getPosition();
    int type = -1;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Honeycomb or later.
        type = cursor.getType(i);

        if (type == Cursor.FIELD_TYPE_BLOB) {
            type = FIELD_TYPE_BLOB;
        } else if (type == Cursor.FIELD_TYPE_FLOAT) {
            type = FIELD_TYPE_FLOAT;
        } else if (type == Cursor.FIELD_TYPE_INTEGER) {
            type = FIELD_TYPE_INTEGER;
        } else if (type == Cursor.FIELD_TYPE_NULL) {
            type = FIELD_TYPE_NULL;
        } else if (type == Cursor.FIELD_TYPE_STRING) {
            type = FIELD_TYPE_STRING;
        }
    } else {                                           // Before Honeycomb
        if (cursorWindow.isNull(pos, i)) {
            type = FIELD_TYPE_NULL;
        } else if (cursorWindow.isLong(pos, i)) {
            type = FIELD_TYPE_INTEGER;
        } else if (cursorWindow.isFloat(pos, i)) {
            type = FIELD_TYPE_FLOAT;
        } else if (cursorWindow.isString(pos, i)) {
            type = FIELD_TYPE_STRING;
        } else if (cursorWindow.isBlob(pos, i)) {
            type = FIELD_TYPE_BLOB;
        }
    }

    return type;
}
 
Example 9
Source Project: cordova-plugin-sms-receive   File: SMSReceive.java    License: MIT License 5 votes vote down vote up
private JSONObject getJsonFromCursor(Cursor cur) {
	JSONObject json = new JSONObject();
	int nCol = cur.getColumnCount();
	String keys[] = cur.getColumnNames();
	try {
		for (int j=0; j<nCol; j++) {
			switch(cur.getType(j)) {
				case Cursor.FIELD_TYPE_NULL:
					json.put(keys[j], JSONObject.NULL);
				break;
				case Cursor.FIELD_TYPE_INTEGER:
					json.put(keys[j], cur.getLong(j));
				break;
				case Cursor.FIELD_TYPE_FLOAT:
					json.put(keys[j], cur.getFloat(j));
				break;
				case Cursor.FIELD_TYPE_STRING:
					json.put(keys[j], cur.getString(j));
				break;
				case Cursor.FIELD_TYPE_BLOB:
					json.put(keys[j], cur.getBlob(j));
				break;
			}
		}
	}
	catch (Exception e) {
		return null;
	}
	return json;
}
 
Example 10
Source Project: SqliteLookup   File: DbSqlite.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * set data in cursor to ResultSet List
 * @param cursor
 * @param resultList the data will set in it
 */
private void parseCursorToResult(Cursor cursor,List<ResultSet> resultList){
	int columnCount;
	int columnType;
	Object columnVal = null;
	while (cursor.moveToNext()) {
		columnCount = cursor.getColumnCount();
		ResultSet result = new ResultSet();
		for (int index = 0; index < columnCount; ++index) {
			columnType = cursor.getType(index);
			switch (columnType) {
			case Cursor.FIELD_TYPE_BLOB:
				columnVal = cursor.getBlob(index);
				break;
			case Cursor.FIELD_TYPE_FLOAT:
				columnVal = cursor.getDouble(index);
				break;
			case Cursor.FIELD_TYPE_INTEGER:
				columnVal = cursor.getLong(index);
				break;
			case Cursor.FIELD_TYPE_NULL:
				columnVal = null;
				break;
			default:
				columnVal = cursor.getString(index);
				break;
			}
			result.setValue(cursor.getColumnName(index), columnVal);
		}
		resultList.add(result);
	}
}
 
Example 11
Source Project: FireFiles   File: DataBaseUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static int getTypeOfObject(Object obj) {
    if (obj == null) {
        return Cursor.FIELD_TYPE_NULL;
    } else if (obj instanceof byte[]) {
        return Cursor.FIELD_TYPE_BLOB;
    } else if (obj instanceof Float || obj instanceof Double) {
        return Cursor.FIELD_TYPE_FLOAT;
    } else if (obj instanceof Long || obj instanceof Integer
            || obj instanceof Short || obj instanceof Byte) {
        return Cursor.FIELD_TYPE_INTEGER;
    } else {
        return Cursor.FIELD_TYPE_STRING;
    }
}
 
Example 12
Source Project: FireFiles   File: DataBaseUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static int getTypeOfObject(Object obj) {
    if (obj == null) {
        return Cursor.FIELD_TYPE_NULL;
    } else if (obj instanceof byte[]) {
        return Cursor.FIELD_TYPE_BLOB;
    } else if (obj instanceof Float || obj instanceof Double) {
        return Cursor.FIELD_TYPE_FLOAT;
    } else if (obj instanceof Long || obj instanceof Integer
            || obj instanceof Short || obj instanceof Byte) {
        return Cursor.FIELD_TYPE_INTEGER;
    } else {
        return Cursor.FIELD_TYPE_STRING;
    }
}
 
Example 13
Source Project: BeMusic   File: MediaUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static List<Song> getAudioList (Cursor cursor) {
    List<Song> audioList = null;
    if (cursor.getCount() > 0) {
        audioList = new ArrayList<Song>();
        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
            Bundle bundle = new Bundle ();
            for (int i = 0; i < AUDIO_KEYS.length; i++) {
                final String key = AUDIO_KEYS[i];
                final int columnIndex = cursor.getColumnIndex(key);
                final int type = cursor.getType(columnIndex);
                switch (type) {
                    case Cursor.FIELD_TYPE_BLOB:
                        break;
                    case Cursor.FIELD_TYPE_FLOAT:
                        float floatValue = cursor.getFloat(columnIndex);
                        bundle.putFloat(key, floatValue);
                        break;
                    case Cursor.FIELD_TYPE_INTEGER:
                        int intValue = cursor.getInt(columnIndex);
                        bundle.putInt(key, intValue);
                        break;
                    case Cursor.FIELD_TYPE_NULL:
                        break;
                    case Cursor.FIELD_TYPE_STRING:
                        String strValue = cursor.getString(columnIndex);
                        bundle.putString(key, strValue);
                        break;
                }
            }
            Song audio = new Song(bundle);
            audioList.add(audio);
        }
    }

    cursor.close();
    return audioList;
}
 
Example 14
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    Cursor source = super.query(uri, projection, selection, selectionArgs, sortOrder);

    String[] columnNames = source.getColumnNames();
    String[] newColumnNames = columnNamesWithData(columnNames);
    if (columnNames == newColumnNames) return source;

    MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount());

    source.moveToPosition(-1);
    while (source.moveToNext()) {
        MatrixCursor.RowBuilder row = cursor.newRow();
        for (int i = 0; i < columnNames.length; i++) {
            switch (source.getType(i)) {
                case Cursor.FIELD_TYPE_INTEGER:
                    row.add(source.getInt(i));
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    row.add(source.getFloat(i));
                    break;
                case Cursor.FIELD_TYPE_STRING:
                    row.add(source.getString(i));
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    row.add(source.getBlob(i));
                    break;
                case Cursor.FIELD_TYPE_NULL:
                default:
                    row.add(null);
                    break;
            }
        }
    }

    source.close();
    return cursor;
}
 
Example 15
public static void printCursor(Uri uri, Cursor c) {
    XLog.d("%s", uri.toString());
    if (c == null) {
        return;
    }
    boolean hasNext = c.moveToNext();
    if (!hasNext) {
        return;
    }

    int columnCount = c.getColumnCount();
    String[] columnNames = c.getColumnNames();
    int[] columnTypes = new int[columnCount];
    for (int i = 0; i < columnCount; i++) {
        columnTypes[i] = c.getType(i);
    }
    c.moveToPrevious();
    while (c.moveToNext()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < columnCount; i++) {
            Object value = null;
            int columnType = columnTypes[i];
            if (columnType == Cursor.FIELD_TYPE_INTEGER) {
                c.getInt(i);
            }
            switch (columnType) {
                case Cursor.FIELD_TYPE_INTEGER:
                    value = c.getInt(i);
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    value = c.getBlob(i);
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    value = c.getFloat(i);
                    break;
                case Cursor.FIELD_TYPE_STRING:
                    value = c.getString(i);
                    break;
                default:
                case Cursor.FIELD_TYPE_NULL:
                    break;
            }
            sb.append(columnNames[i]).append(" = ").append(value).append(", ");
        }
        sb.append("\n");
        XLog.d("%s", sb.toString());
    }
}
 
Example 16
private void bindArguments(PreparedStatement statement, Object[] bindArgs) {
    final int count = bindArgs != null ? bindArgs.length : 0;
    if (count != statement.mNumParameters) {
        throw new SQLiteBindOrColumnIndexOutOfRangeException(
                "Expected " + statement.mNumParameters + " bind arguments but "
                + count + " were provided.");
    }
    if (count == 0) {
        return;
    }

    final long statementPtr = statement.mStatementPtr;
    for (int i = 0; i < count; i++) {
        final Object arg = bindArgs[i];
        switch (DatabaseUtils.getTypeOfObject(arg)) {
            case Cursor.FIELD_TYPE_NULL:
                nativeBindNull(mConnectionPtr, statementPtr, i + 1);
                break;
            case Cursor.FIELD_TYPE_INTEGER:
                nativeBindLong(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).longValue());
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                nativeBindDouble(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).doubleValue());
                break;
            case Cursor.FIELD_TYPE_BLOB:
                nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[])arg);
                break;
            case Cursor.FIELD_TYPE_STRING:
            default:
                if (arg instanceof Boolean) {
                    // Provide compatibility with legacy applications which may pass
                    // Boolean values in bind args.
                    nativeBindLong(mConnectionPtr, statementPtr, i + 1,
                            ((Boolean)arg).booleanValue() ? 1 : 0);
                } else {
                    nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString());
                }
                break;
        }
    }
}
 
Example 17
Source Project: sqlite-android   File: SQLiteConnection.java    License: Apache License 2.0 4 votes vote down vote up
private void bindArguments(PreparedStatement statement, Object[] bindArgs) {
    final int count = bindArgs != null ? bindArgs.length : 0;
    if (count != statement.mNumParameters) {
        String message = "Expected " + statement.mNumParameters + " bind arguments but "
            + count + " were provided.";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            throw new SQLiteBindOrColumnIndexOutOfRangeException(message);
        } else {
            throw new SQLiteException(message);
        }
    }
    if (count == 0) {
        return;
    }

    final long statementPtr = statement.mStatementPtr;
    for (int i = 0; i < count; i++) {
        final Object arg = bindArgs[i];
        switch (getTypeOfObject(arg)) {
            case Cursor.FIELD_TYPE_NULL:
                nativeBindNull(mConnectionPtr, statementPtr, i + 1);
                break;
            case Cursor.FIELD_TYPE_INTEGER:
                nativeBindLong(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).longValue());
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                nativeBindDouble(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).doubleValue());
                break;
            case Cursor.FIELD_TYPE_BLOB:
                nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[])arg);
                break;
            case Cursor.FIELD_TYPE_STRING:
            default:
                if (arg instanceof Boolean) {
                    // Provide compatibility with legacy applications which may pass
                    // Boolean values in bind args.
                    nativeBindLong(mConnectionPtr, statementPtr, i + 1, (Boolean) arg ? 1 : 0);
                } else {
                    nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString());
                }
                break;
        }
    }
}
 
Example 18
Source Project: easyDAO   File: Utils.java    License: Apache License 2.0 4 votes vote down vote up
public static <T extends BaseEntity> List<T> cursor2Entity(Class<T> clazz, Cursor cursor) throws DBException {
    List<T> objList = new ArrayList<>();
    Field[] fields = getDeclaredField(clazz);
    try {
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                T obj = clazz.newInstance();

                for (int i = 0; i < cursor.getColumnCount(); i++) {
                    String strColName = cursor.getColumnName(i);
                    for (Field field : fields) {
                        if (field.getName().equals(strColName)) {
                            strColName = toUpperCaseFirstOne(strColName);
                            if (cursor.getType(i) == Cursor.FIELD_TYPE_NULL) {
                                continue;
                            } else if (cursor.getType(i) == Cursor.FIELD_TYPE_FLOAT) {
                                clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                        cursor.getFloat(i));
                            } else if (cursor.getType(i) == Cursor.FIELD_TYPE_INTEGER) {
                                if (field.getGenericType().toString().equals("class java.lang.Boolean")
                                        || field.getGenericType().toString().equals("boolean")) {
                                    // e.g. boolean isOk; public boolean isOk(){ return isOk; }   public void setOk(){}
                                    clazz.getMethod("set" + strColName.replaceFirst("Is", ""), field.getType()).invoke(obj,
                                            cursor.getInt(i) == 1 ? true : false);
                                } else if (field.getGenericType().toString().equals("class java.lang.Integer")
                                        || field.getGenericType().toString().equals("int")) {
                                    clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                            cursor.getInt(i));
                                } else if (field.getGenericType().toString().equals("class java.lang.Long")
                                        || field.getGenericType().toString().equals("long")) {
                                    clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                            (long) cursor.getInt(i));
                                } else if (field.getGenericType().toString().equals("class java.lang.Short")
                                        || field.getGenericType().toString().equals("short")) {
                                    clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                            (short) cursor.getInt(i));
                                } else if (field.getGenericType().toString().equals("class java.lang.Byte")
                                        || field.getGenericType().toString().equals("byte")) {
                                    clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                            (byte) cursor.getInt(i));
                                }
                            } else if (cursor.getType(i) == Cursor.FIELD_TYPE_STRING) {
                                clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                        cursor.getString(i));
                            } else if (cursor.getType(i) == Cursor.FIELD_TYPE_BLOB) {
                                clazz.getMethod("set" + strColName, field.getType()).invoke(obj,
                                        cursor.getBlob(i));
                            } else {
                                throw new DBException(null);
                            }
                            break;
                        }
                    }
                }
                objList.add(obj);
                cursor.moveToNext();
            }
            return objList;
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new DBException(null);
    }
    return objList;
}
 
Example 19
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@MediumTest
@Test
public void testBlob() {
    // create table
    mDatabase.execSQL(
        "CREATE TABLE test (_id INTEGER PRIMARY KEY, s TEXT, d REAL, l INTEGER, b BLOB);");
    // insert blob
    Object[] args = new Object[4];
    
    byte[] blob = new byte[1000];
    byte value = 99;
    Arrays.fill(blob, value);        
    args[3] = blob;
    
    String s = "text";
    args[0] = s;
    Double d = 99.9;
    args[1] = d;
    Long l = (long)1000;
    args[2] = l;
    
    String sql = "INSERT INTO test (s, d, l, b) VALUES (?,?,?,?)";
    mDatabase.execSQL(sql, args);
    // use cursor to access blob
    Cursor c = mDatabase.query("test", null, null, null, null, null, null);        
    c.moveToNext();
    ContentValues cv = new ContentValues();
    //DatabaseUtils.cursorRowToContentValues(c, cv);
    String[] columns = c.getColumnNames();
    int length = columns.length;
    for (int i = 0; i < length; i++) {
        if (c.getType(i) == Cursor.FIELD_TYPE_BLOB) {
            cv.put(columns[i], c.getBlob(i));
        } else {
            cv.put(columns[i], c.getString(i));
        }
    }
    
    int bCol = c.getColumnIndexOrThrow("b");
    int sCol = c.getColumnIndexOrThrow("s");
    int dCol = c.getColumnIndexOrThrow("d");
    int lCol = c.getColumnIndexOrThrow("l");
    byte[] cBlob =  c.getBlob(bCol);
    assertTrue(Arrays.equals(blob, cBlob));
    assertEquals(s, c.getString(sCol));
    assertEquals(d, new Double(c.getDouble(dCol)));
    assertEquals((long)l, c.getLong(lCol));
    c.close();
}
 
Example 20
Source Project: squidb   File: ExtraUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Returns data type of the given object's value.
 *<p>
 * Returned values are
 * <ul>
 *   <li>{@link Cursor#FIELD_TYPE_NULL}</li>
 *   <li>{@link Cursor#FIELD_TYPE_INTEGER}</li>
 *   <li>{@link Cursor#FIELD_TYPE_FLOAT}</li>
 *   <li>{@link Cursor#FIELD_TYPE_STRING}</li>
 *   <li>{@link Cursor#FIELD_TYPE_BLOB}</li>
 *</ul>
 *</p>
 *
 * @param obj the object whose value type is to be returned
 * @return object value type
 */
public static int getTypeOfObject(Object obj) {
    if (obj == null) {
        return Cursor.FIELD_TYPE_NULL;
    } else if (obj instanceof byte[]) {
        return Cursor.FIELD_TYPE_BLOB;
    } else if (obj instanceof Float || obj instanceof Double) {
        return Cursor.FIELD_TYPE_FLOAT;
    } else if (obj instanceof Long || obj instanceof Integer
            || obj instanceof Short || obj instanceof Byte) {
        return Cursor.FIELD_TYPE_INTEGER;
    } else {
        return Cursor.FIELD_TYPE_STRING;
    }
}