我無法將記錄插入到我的應用程序本地數據庫。我從Web服務獲取數據,並試圖將它們存儲在我的應用程序本地sqlite數據庫中,但我沒有得到這樣的表錯誤。 這是我用於創建表格&的DatabaseHelper類的代碼。插入sqlite數據庫時不存在此列存在錯誤
private static final String CREATE_MERCHANT_DETAILS = "CREATE TABLE " + TABLE_MERCHANT_DETAILS +
" (" + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_NAME + " TEXT, "
+ KEY_LOGO + "TEXT, "
+ KEY_BACKGROUND + "TEXT, "
+ KEY_PRODUCT + "TEXT, "
+ KEY_PRODUCT_ID + "TEXT, "
+ KEY_TYPE + "TEXT, "
+ KEY_DENOMINATION + "TEXT);";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_MERCHANT_DETAILS);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public void insertAMerchant(String name, String logo, String background, String product, String productId, String type, String denomination) {
database = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(KEY_NAME, name);
contentValues.put(KEY_LOGO, logo);
contentValues.put(KEY_BACKGROUND, background);
contentValues.put(KEY_PRODUCT, product);
contentValues.put(KEY_PRODUCT_ID, productId);
contentValues.put(KEY_TYPE, type);
contentValues.put(KEY_DENOMINATION, denomination);
database.insert(TABLE_MERCHANT_DETAILS, null, contentValues);
}
CREATE_MERCHANT_DETAILS,code? – Skynet
private static final String CREATE_MERCHANT_DETAILS =「CREATE TABLE」+ TABLE_MERCHANT_DETAILS +「(」+ KEY_ID +「INTEGER PRIMARY KEY AUTOINCREMENT,」+ KEY_NAME +「TEXT」+ KEY_LOGO +「TEXT」+ KEY_BACKGROUND +「TEXT」+ KEY_PRODUCT +「TEXT」+ KEY_PRODUCT_ID +「TEXT」+ KEY_TYPE +「TEXT」+ KEY_DENOMINATION +「TEXT」;「; –
檢出:http://www.tutorialspoint.com/android/android_sqlite_database.htm –