Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

android - Sqlite Exception, syntax error

i'm still learning Android development, And i have a problem creating an sqlite database table. here is a part of my code :

`

private static final String CREATE_ADS_PICTURE = "CREATE TABLE "
        + AdsBDD.TABLE_ADS_PICTURE + "(" + AdsBDD.ID_PICS
        + " INTEGER PRIMARY KEY AUTOINCREMENT ," + AdsBDD.AD_ID
        + " INTEGER NOT NULL," + AdsBDD.PICTURE + " TEXT," + AdsBDD.FOLDER
        + " TEXT," + AdsBDD.ORDER_NO + " INTEGER NOT NULL);";

private static final String CREATE_AGENCES = "CREATE TABLE "
        + AgencesBDD.TABLE_AGENCES + "(" + AgencesBDD.ID
        + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + AgencesBDD.GROUP
        + " INTEGER," + AgencesBDD.USERNAME + " TEXT," + AgencesBDD.EMAIL
        + " TEXT," + AgencesBDD.CONTACT_NAME + " TEXT,"
        + AgencesBDD.REGISTRATION_DATE + " TEXT," + AgencesBDD.ACTIVATION
        + " TEXT," + AgencesBDD.ACTIVE + " INTEGER," + AgencesBDD.STORE
        + " INTEGER," + AgencesBDD.STORE_BANNER + " TEXT,"
        + AgencesBDD.RATING + " REAL," + AgencesBDD.LANGUAGE + " TEXT,"
        + AgencesBDD.IDENTITY + " TEXT," + AgencesBDD.ADDRESS + " TEXT,"
        + AgencesBDD.PHONE + " TEXT," + AgencesBDD.COMPANY + " TEXT,"
        + AgencesBDD.WEBPAGE + " TEXT," + AgencesBDD.CODE_POSTAL + " TEXT,"
        + AgencesBDD.JE_SUIS_UN + " TEXT," + AgencesBDD.VILLE + " TEXT,"
        + AgencesBDD.VIDEO + " TEXT);";

    @Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(CREATE_ADS_PICTURE);
    db.execSQL(CREATE_AGENCES);
}



   public class AgencesBDD {
public static final String TABLE_AGENCES = "agences";

public static final String ID = "id";
public static final String GROUP = "group";
public static final String USERNAME = "username";
public static final String EMAIL = "email";
public static final String CONTACT_NAME = "contact_name";
public static final String REGISTRATION_DATE = "registration_date";
public static final String ACTIVATION = "activation";
public static final String ACTIVE = "active";
public static final String STORE = "store";
public static final String STORE_BANNER = "store_banner";
public static final String RATING = "rating";
public static final String LANGUAGE = "language";
public static final String IDENTITY = "identity";
public static final String ADDRESS = "address";
public static final String PHONE = "phone";
public static final String COMPANY = "company";
public static final String WEBPAGE = "webpage";
public static final String CODE_POSTAL = "code_postal";
public static final String JE_SUIS_UN = "je_suis_un";
public static final String VILLE = "ville";
public static final String VIDEO = "video";

` So the problem is that Sqlite throws this exception for the table AGENCES, but the Table AD_PICTURE works fine:

03-08 14:36:01.892: E/AndroidRuntime(10822): FATAL EXCEPTION: main
03-08 14:36:01.892: E/AndroidRuntime(10822): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infonetdiffusion.immohabitation/com.infonetdiffusion.immohabitation.FragmentBaseActivity}: android.database.sqlite.SQLiteException: near "group": syntax error (code 1): , while compiling: CREATE TABLE agences(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,group INTEGER,username TEXT,email TEXT,contact_name TEXT,registration_date TEXT,activation TEXT,active INTEGER,store INTEGER,store_banner TEXT,rating REAL,language TEXT,identity TEXT,address TEXT,phone TEXT,company TEXT,webpage TEXT,code_postal TEXT,je_suis_un TEXT,ville TEXT,video TEXT);

it should be easy to fix, but i can't find where i'm wrong... any help would be apreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you are using sqlite keyword as column name i.e. group sqliteKeyword which is restrict


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...