测试代码:
> String x = "30000000000.222";
> String y = "20000000000.444";
> double x1 = Double.parseDouble(x);
> double y1 = Double.parseDouble(y);
>
> ContentValues vValue51 = new ContentValues();
> vValue51.put(DatabaseStructure.fTmpAttr_X3 , x1 );
> vDatabase.insertData(DatabaseStructure.cTblTemporary3, vValue51);
> ContentValues vValue61 = new ContentValues();
> vValue61.put(DatabaseStructure.fTmpAttr_X3 , y1 );
> vDatabase.insertData(DatabaseStructure.cTblTemporary3, vValue61);
> vDatabase.closeDatabase();
>
>
>
> List<Map<String, String>> vListData2 = new
> ArrayList<Map<String,String>>(); String vQuerY32;
>
>
> vQuerY32 = "Select SUM(" + DatabaseStructure.fTmpAttr_X3 + " ) 'jik' " +
> "From " + DatabaseStructure.cTblTemporary3;
>
> vDatabase = new DatabaseHandler(getApplicationContext());
> vListData2 = vDatabase.getListData(vQuerY32);
> vDatabase.closeDatabase();
I tried many data type for column
> vQuery = "create table " + cTblTemporary3 +
> "("+
> fTmpAttr_ID3 + " integer primary key, " +
> fTmpAttr_V3 + " DECIMAL(10,5), " +
> fTmpAttr_W3 + " FLOAT , " +
> fTmpAttr_X3 + " REAL, " +
> fTmpAttr_Y3 + " DOUBLE PRECISION, " +
> fTmpAttr_Z3 + " double " +
> ")"; vSQL.execSQL(vQuery);
====================== getListDataFunction ======================== ===================
public List<Map<String, String>> getListData(String vQuery) { List<Map<String, String>> vListData = new ArrayList<Map<String,String>>(); Cursor vCursor = getCursorData(vQuery); int vLength = vCursor.getColumnCount(); String[] vFields = new String[vLength]; if (vCursor.getCount() > 0){ for (int i = 0; i < vLength; i++) vFields[i] = vCursor.getColumnName(i); vCursor.moveToFirst(); while (!vCursor.isAfterLast()) { Map<String, String> vMapData = new HashMap<String, String>(); for (int i = 0; i < vLength; i++) vMapData.put(vFields[i], vCursor.getString(i)); vListData.add(vMapData); vCursor.moveToNext(); } } vCursor.close(); return vListData; }
我记录结果
Log.d(&#34; TEST&#34;,vListData2.get(0).get(&#34; jik&#34;));
,结果不是50000000000.666而是5e + 10,我怎么能得到50000000000.666的结果呢?请帮助这个新手:(