我有一个这样定义的表
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);
当我获取时,我总是得到错误的数据。它在我的所有领域都给了我非常高的数字。我不确定我做错了什么。(PS 我是 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();
}