奇怪的 sqlite 问题。不从变量和参数插入/更新一致的值
最近我遇到了很多数据库问题。我目前的情况是,记录不是用我告诉它的值创建的。它创建“00”而不是“100”。奇怪的是,这只发生在 android 模拟器中。我正在使用的设备(Driod Incredible)可以正常运行相同的代码。不过,我还没有在手机上看过数据库,因为eclipse由于某种原因没有打开data文件夹。当我决定从模拟器中提取数据库时,我才发现这一点(因为我遇到了其他 sqlite 问题,如果您精通该领域,请查看我的其他问题)。由于游标索引错误,索引大小为 0,我比预期更早地强制关闭。这是因为我正在查找的值是 100,而它被创建为 00。这是什么鬼?
public void createEmptyProfile(String SaveSlot) {
ContentValues initialValues = new ContentValues();
//ITEM 100
initialValues.put(ITEM, "100");
initialValues.put(VALUE1, "100");
initialValues.put(SAVE_SLOT, SaveSlot);
initialValues.put(CATEGORY, "S");
mDb.insert(DATABASE_PUSHERS_TABLE, null, initialValues);
initialValues.clear();
//ITEM 99
initialValues.put(ITEM, "99");
initialValues.put(VALUE1, "0");
initialValues.put(SAVE_SLOT, SaveSlot);
initialValues.put(CATEGORY, "S");
mDb.insert(DATABASE_PUSHERS_TABLE, null, initialValues);
initialValues.clear();
return;
数据库有项目 99,但项目 00 而不是 100。所有其他值都是正确的。有很多项目。
表创建:
"create table profiles (_id integer primary key autoincrement, " +
"save_slot text not null,item text, value1 text, " +
"value2 text, category text);"
I've been running into quite a few database problems lately. My current situation is that a record is not created with the the value I tell it to. It creates "00" instead of "100". The weird thing is that this only happens in the android emulator. The device i'm using (Driod Incredible) runs the same code fine. However, I have not looked at the database on the phone, because eclipse does not open the data folder for some reason. I only discovered this when i decided to pull the database from emulator(because of other sqlite issues that i am having please look at my other questions if you are proficient in this area) . I got a force close earlier than expected from a cursor index error, index size of 0. This is because the value i'm looking for is 100 and it was created as 00. Whats the dill?
public void createEmptyProfile(String SaveSlot) {
ContentValues initialValues = new ContentValues();
//ITEM 100
initialValues.put(ITEM, "100");
initialValues.put(VALUE1, "100");
initialValues.put(SAVE_SLOT, SaveSlot);
initialValues.put(CATEGORY, "S");
mDb.insert(DATABASE_PUSHERS_TABLE, null, initialValues);
initialValues.clear();
//ITEM 99
initialValues.put(ITEM, "99");
initialValues.put(VALUE1, "0");
initialValues.put(SAVE_SLOT, SaveSlot);
initialValues.put(CATEGORY, "S");
mDb.insert(DATABASE_PUSHERS_TABLE, null, initialValues);
initialValues.clear();
return;
the database has item 99, but item 00 instead of 100. All other values are correct. There are numerous items.
table create:
"create table profiles (_id integer primary key autoincrement, " +
"save_slot text not null,item text, value1 text, " +
"value2 text, category text);"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我添加了一个单引号并修复了它。
从
到
I added a single quote and that fixed it.
from
to