尝试创建数据库表时遇到SQLiteException错误语法错误(代码1)

时间:2017-03-15 22:38:01

标签: java android sqlite android-sqlite database-connection

刚刚进入Android开发的新用户!在尝试在Android Studio中创建表时,我似乎无法解决我一直收到的SQLiteException错误。这是一个语法错误,但我无法分辨线上的语法错误,尽管检查语法错误/ SQLiteExceptions上的类似帖子。我在下面的LoginDataBaseAdapater.java类中包含了一段代码:

公共类LoginDataBaseAdapter {

DummyRetriever

我不断收到的错误消息如下:

private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "regDetailsDatabase.db";
private static final String TABLE_REG_DETAILS = "Registration Details";

public static final int COLUMN_ID = 1;
public static final String COLUMN_EMAIL_ADDRESS = "email_address";
public static final String COLUMN_USER_NAME = "user_name";
public static final String COLUMN_PASSWORD = "password";
public static final String COLUMN_DATE_OF_BIRTH = "dob";
public static final String COLUMN_MOBILE_NUMBER = "mobile_number";


static final String DATABASE_CREATE = "CREATE TABLE " + TABLE_REG_DETAILS + " ("+ COLUMN_ID + " INTEGER PRIMARY KEY, " + COLUMN_EMAIL_ADDRESS + " TEXT, " + COLUMN_USER_NAME + " TEXT, " + COLUMN_PASSWORD + " TEXT, " + COLUMN_DATE_OF_BIRTH + " TEXT, " + COLUMN_MOBILE_NUMBER + " TEXT " + ")";

语法错误似乎接近create table语句的TABLE_REG_DETAILS部分,但我不能在我的生活中弄清楚为什么会发生这种情况。有谁知道可能导致这个SQLiteException的原因是什么?非常感谢提前!

1 个答案:

答案 0 :(得分:2)

private static final String TABLE_REG_DETAILS = "registration_details";

public static final String COLUMN_ID = "_id";

列的名称不能是数字