Android sqlite 資料型別

2021-07-03 16:12:45 字數 1080 閱讀 3505

場景:一直做金融行業專案,所以資料的精確性十分重要

執行**查詢資料(資料精確到小數點2位)和直接執行sql所查詢資料不一致,經排查發現

value = cursor.getstring(cursor.getcolumnindex(ss[i]));在作怪,此方法對double資料進行了怎樣處理,還需深究

解決方法如下

if(cursor.gettype(cursor.getcolumnindex(ss[i])) == cursor.field_type_float) else

sqlite具有以下五種資料型別:

1.null:空值。

2.integer:帶符號的整型,具體取決有存入數字的範圍大小。

3.real:浮點數字,儲存為8-byte ieee浮點數。

4.text:字串文字。

5.blob:二進位制物件。

/** value returned by if the specified column is null */

static final int field_type_null = 0;

/** value returned by if the specified  column type is integer */

static final int field_type_integer = 1;

/** value returned by if the specified column type is float */

static final int field_type_float = 2;

/** value returned by if the specified column type is string */

static final int field_type_string = 3;

/** value returned by if the specified column type is blob */

static final int field_type_blob = 4;

android sqlite 資料儲存

android 專門提供了乙個sqliteopenhelper幫助類,管理資料庫,借助這個類可以對資料庫進行建立和公升級。編寫藍芽配對列表寫入資料庫的helper類繼承抽象類sqliteopenhelper,用於建立資料庫和表bt pair devices public classbondeddev...

android SQLite大資料插入優化

sqlitedatabase db this.getwritabledatabase 獲取資料庫可寫物件 db.begintransaction 啟動事務 try 以上資料操作全部成功,通過標記settransactionsuccessful為true,事務才提交,否則回滾 預設標記為false d...

Android SQLite資料庫操作

資料庫操作類 sqlitedatabase 在android系統之中,乙個android.database,sqlite.sqlitedatebase類的例項都代表了乙個sqlite資料庫的操作,通過sqlitedatabase類可以執行sql語句,可以完成對資料表的增加,修改,刪除,查詢等操作,在...