开发者

Android, SQL Database Failure 1 syntax error? Can't find what catlog is talking about

Database - Failure 1 (near "text" : syntax error) on 0x25c768 when preparing...

This is the error that shows up in LogCat when I try to run my app. I have the following code setting up the database:

private static final String DATABASE_NAME = "recipesDB";
private static final String DATABASE_TABLE = "recipes";
private static int DATABASE_VERSION = 1;

public static final String KEY_NAME = "name";
public static final String KEY_TYPE = "type";
public static final String KEY_INGREDIENTS = "ingredients";
public static final String KEY_NOTE开发者_开发知识库S = "notes";
public static final String KEY_BOIL = "boil";
public static final String KEY_PRIMARY = "primary";
public static final String KEY_SECONDARY = "secondary";
public static final String KEY_ROWID = "_id";
private DatabaseHelper mDbHelper; // DatabaseHelper is an inner class extending SQLiteOpenHelper

private SQLiteDatabase mDb;

private static final String DATABASE_CREATE = 
    "create table " + DATABASE_TABLE + " ("
    + KEY_ROWID + " integer primary key autoincrement, "
    + KEY_INGREDIENTS + " text not null, "
    + KEY_NOTES + " text not null, "
    + KEY_BOIL + " text not null, "
    + KEY_PRIMARY + " text not null, "
    + KEY_SECONDARY + " text not null); ";

private final Context cntx;

public recipesDB(Context cnt){
    this.cntx = cnt;
}

I'm pretty lost as to why I am getting this error since the code and syntax seem to be fine. I get a run-time error when I run the app on my phone and click on the button which opens up the activityList. There is more code not shown that opens up and catches a SQLExpection on open(), etc.

Any suggestions?


Try renaming the column "primary" -- it's a reserved word (as in primary key autoincrement...) and may be causing SQLite to choke.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜