2012-01-02 78 views
-2

林有一些麻煩,在Android的創造中的SQLite數據庫。這裏我initiliaze鍵:沒有這樣的表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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); 
+0

你能發表聲明給出異常嗎?您的代碼中沒有足夠的信息... – 2012-01-02 19:23:20

+0

我給出了錯誤顯示的位置以及日誌貓的錯誤。希望這會給出更好的含義。 – Mustii1989 2012-01-02 19:26:53

+0

我對此問題進行了downvoting並對其進行投票關閉爲「太本地化」。請使用Stack Overflow來回答你自己無法回答的問題。它不是人們幫助你調試你的教程的平臺 – 2012-01-02 19:34:57

回答

2

好了,執行的語句是

INSERT INTO favorites ... 

儘管你可能想

INSERT INTO titles ... 

我猜,要麼你DATABASE_TABLEDATABASE_CREATE不變的是錯誤的...你應該已經發現了這一點自己,雖然

+0

不,我真的發現了什麼錯誤。讓我告訴你,它不是那麼容易找到..在Android中,一旦你使用表的名字例如TITLE喜歡來自教程的一個你可以改變它..你必須從你的手機刪除應用程序來做到這一點..謝謝你SOOO heelpfull .. – Mustii1989 2012-01-02 19:57:15

+0

這是正常的。事實上,當你升級你的數據庫併發布補丁時,你必須管理升級對舊錶進行更改,否則將崩潰在舊的應用程序版本 – StErMi 2012-01-02 20:01:37

+0

它似乎有很多工作在它..但現在它工作..謝謝 – Mustii1989 2012-01-02 20:19:34

0

是的,它相當清楚。您正嘗試向表格收藏夾中插入值,但您創建的字符串具有切片。

其中之一。也許你是一個憤怒的複製/粘貼的受害者。