我有一个表定义为
String currencyTableQueryString = "create table if not exists "
+ CURRENCY_NAME + " (" + CURRENCY_ROW_ID
+ " integer primary key autoincrement not null,"
+ CURRENCY_USD + " double," + CURRENCY_INR + " double,"
+ CURRENCY_EUR + " double," + CURRENCY_GBP + " double"
+ ");";
我从JSON中将数据存储在此表中。 例如,我已存储此数据
CURRENCY_USD = 1.0
CURRENCY_INR = 53.997369
CURRENCY_EUR = 0.764879
CURRENCY_GBP = 0.658136
在我的下一个活动中,我从数据库中获取此数据
Ccursor = db.query(CURRENCY_NAME, new String[] { CURRENCY_ROW_ID, CURRENCY_USD, CURRENCY_INR,
CURRENCY_EUR, CURRENCY_GBP }, null, null, null, null, null);
我拿取时总是得到错误的数据。它给了我所有领域中非常高的数字。我不确定我做错了什么。 (P.S.我是Java和Android编程的新手)。
这是插入上述数字时获取的输出
CURRENCY_USD = 1.072693248E9
CURRENCY_INR = -1.0925335E8
CURRENCY_EUR = -1.80473634E8
CURRENCY_GBP = 9.1173113E7
有人可以指导我这里出了什么问题吗?
这是我的提取光标。
ArrayList<ArrayList<Object>> dataArrays = new ArrayList<ArrayList<Object>>();
Cursor Ccursor;
try {
// ask the database object to create the cursor.
Ccursor = db.query(CURRENCY_NAME, new String[] { CURRENCY_ROW_ID, CURRENCY_USD, CURRENCY_INR,
CURRENCY_EUR, CURRENCY_GBP }, null, null, null, null, null);
// move the cursor's pointer to position zero.
Ccursor.moveToFirst();
// if there is data after the current cursor position, add it
// to the ArrayList.
if (!Ccursor.isAfterLast()) {
do {
ArrayList<Object> dataList = new ArrayList<Object>();
dataList.add(Ccursor.getLong(0));
dataList.add(Ccursor.getDouble(1));
dataList.add(Ccursor.getDouble(2));
dataList.add(Ccursor.getDouble(3));
dataList.add(Ccursor.getDouble(4));
dataArrays.add(dataList);
}
// move the cursor's pointer up one position.
while (Ccursor.moveToNext());
}
Ccursor.close();
} catch (SQLException e) {
Log.e("DB Error in Currency Retreive all", e.toString());
e.printStackTrace();
}