没有这样的表SQLite

时间:2012-01-02 19:12:45

标签: android sqlite

我在Android中的SQLite中创建数据库时遇到了一些麻烦..在这里我初衷了关键:

public final String KEY_ROWID = "_id";
public final String KEY_CategoryId = "CategoryId";
public final String KEY_DealerAddress = "DealerAddress";
public final String KEY_DealerCity = "DealerCity";
public final String KEY_DealerCountry = "DealerCountry";
public final String KEY_DealerLatitude = "DealerLatitude";
public final String KEY_DealerLongitude = "DealerLongitude";
public final String KEY_DealerName = "DealerName";
public final String KEY_DealerWeb = "DealerWeb";
public final String KEY_DealerPhone = "DealerPhone";
public final String KEY_DealerZip = "DealerZip";
public final String KEY_Description = "Description";
public final String KEY_EndDate = "EndDate";
public final String KEY_EndTime = "EndTime";
public final String KEY_Id = "Id";
public final String KEY_Name = "Name";
public final String KEY_PriceBefore = "PriceBefore";
public final String KEY_PriceNow = "PriceNow";
public final String KEY_SavingInPercent = "SavingInPercent";
public final String KEY_StartDate = "StartDate";
public final String KEY_StartTime = "StartTime";
private final String TAG = "DataBase";

private final String DATABASE_NAME = "DealFinders";
private final String DATABASE_TABLE = "Favorites";
private final int DATABASE_VERSION = 1;
private final String DATABASE_CREATE =
    "create table titles (_id integer primary key autoincrement," +
    "CategoryId text not null,"
    + "DealerAddress text not null, DealerCity text not null, DealerCountry text not null, " +
    "DealerLatitude text not null, DealerLongitude text not null, DealerName text not null," +
    "DealerWeb text not null, DealerPhone text not null,Description text not null," +
    "EndDate text not null,EndTime text not null,Id text not null,Name text not null," +
    "PriceBefore text not null, PriceNow text not null, SavingInPercent text not null, " +
    "StartDate text not null, StartTime text not null);";

剩下的就像这个http://www.devx.com/wireless/Article/40842/1954,当然还有一些输入变化。但它一直没有给这样的表?我试图改变表名但它没有帮助..

我看不出应该是什么问题?当我尝试教程它工作得很好,但现在它给了一些麻烦?任何想法??

问题在于将值插入数据库时​​:

id = db.insertTitle(
                        "nej","nej","nej","nej","nej","nej","nej","nej","nej","nej",
                        "nej","nej","nej","nej","nej","nej","nej","nej",
                        "C# 2008 Programmer's Reference",
                        "Wrox");  

错误是:

01-02 20:18:51.512: E/Database(15601): android.database.sqlite.SQLiteException: no such table: 
favorites: , while compiling: INSERT INTO favorites(DealerPhone, Description, DealerCity, 
PriceNow, DealerAddress, SavingInPercent, DealerCountry, PriceBefore, DealerName, Name, 
DealerWeb, EndDate, DealerLongitude, DealerLatitude, CategoryId, StartDate, Id, EndTime, 
StartTime, DealerZip) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);

2 个答案:

答案 0 :(得分:2)

嗯,执行的声明是

INSERT INTO favorites ...

你可能想要

INSERT INTO titles ...

我猜你的DATABASE_TABLEDATABASE_CREATE常数是错的......你应该自己发现这个,不过

答案 1 :(得分:0)

是的,非常清楚。您正在尝试将值插入到表收藏夹中,但您的create String具有切片。

其中任何一个。也许你是一个愤怒的副本/粘贴的受害者。