0
這裏是我的應用程序,該AVD啓動,但是當我嘗試打開應用程序,我得到一個消息的Android SQLiteException
「您的應用程序已停止遺憾的是工作」
這是我logcat的細節:
Caused by: android.database.sqlite.SQLiteException: near "TABLEproducts": syntax error (code 1): , while compiling: CREATE TABLEproducts(_idINTEGER PRIMARY KEY AUTOINCREMENTproductnameTEXT);
任何幫助都不勝感激。
這裏是代碼:TABLE
像"CREATE TABLE "
也是每列名後後
public class MyDB extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "store.db";
public static final String TABLE_PRODUCTS = "products";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_PRODUCTNAME = "productname";
public MyDB(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String query = "CREATE TABLE" + TABLE_PRODUCTS + "(" +
COLUMN_ID + "INTEGER PRIMARY KEY AUTOINCREMENT" +
COLUMN_PRODUCTNAME + "TEXT" +
");";
db.execSQL(query);
}
所致:android.database.sqlite.SQLiteException:近 「productnameTEXT」:語法錯誤(碼1):在編譯:CREATE TABLE產品(_idINTEGER PRIMARY KEY AUTOINCREMENT productnameTEXT); – Veeresh
試試我提供的查詢 – Renjith
是的。這解決了它。謝謝 – Veeresh