首先,我尝试了其他解决方案,但他们并没有为我工作。 这就是我创建表的方式:
String CREATE_DETAILS_TABLE = "CREATE TABLE " + TABLE_DETAIL + "("
+ STATUS + " TEXT," + FIRST_NAME + " TEXT," + LAST_NAME + " TEXT," + EMAIL + " TEXT," + COUNTRY
+ " TEXT," + COUNTRYALPHA2 + " TEXT," + CITY + " TEXT," + ZIP + " TEXT," + ADDRESS
+ " TEXT," + USERACCSTATUS + " TEXT," + SKYPENAME + " TEXT," + COUNTRY_NAME + " TEXT," +
PHONE_CODE + " TEXT," + PHONE + " TEXT," + DEVICEID + " TEXT," + STATUSDESC + " TEXT" + ")";
db.execSQL(CREATE_DETAILS_TABLE);
列和名称:
private static final String TABLE_DETAIL = "detail";
// Details table columns
private static final String STATUS = "Status";
private static final String FIRST_NAME = "FirstName";
private static final String LAST_NAME = "LastName";
private static final String EMAIL = "Email";
private static final String COUNTRY= "Country";
private static final String COUNTRYALPHA2= "CountryAlpha2";
private static final String CITY= "City";
private static final String ZIP = "Zip";
private static final String ADDRESS = "Address";
private static final String USERACCSTATUS = "UserAccStatus";
private static final String SKYPENAME = "SkypeName";
private static final String COUNTRY_NAME = "CountryName";
private static final String PHONE_CODE = "Phonecode";
private static final String PHONE = "Phone";
private static final String DEVICEID = "DeviceIdentificator";
private static final String STATUSDESC = "StatusDescription";
将详细信息添加到表中:
public void addDetails(String status,String firstName,String lastName,String email
,String country,String countryAlpha2,String city,String zip,String address,String userAccStatus
,String skypename,String phonecode,String phone,String countryname,String deviceid,String statusDesc){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(STATUS,status);
contentValues.put(FIRST_NAME,firstName);
contentValues.put(LAST_NAME,lastName);
contentValues.put(EMAIL,email);
contentValues.put(COUNTRY,country);
contentValues.put(COUNTRYALPHA2,countryAlpha2);
contentValues.put(CITY,city);
contentValues.put(ZIP,zip);
contentValues.put(ADDRESS,address);
contentValues.put(USERACCSTATUS,userAccStatus);
contentValues.put(SKYPENAME,skypename);
contentValues.put(PHONE_CODE,phonecode);
contentValues.put(PHONE,phone);
contentValues.put(COUNTRY_NAME,countryname);
contentValues.put(DEVICEID,deviceid);
contentValues.put(STATUSDESC,statusDesc);
long id = db.insert(TABLE_DETAIL,null,contentValues);
db.close();
Log.d(TAG,"User Details added into sqlite: " + id);
}
并在尝试添加详细信息时出现此错误:
android.database.sqlite.SQLiteException:表格详细信息没有列 命名为StatusDescription(代码1):,同时编译:INSERT INTO 细节(状态,邮编,电子邮件,地址,UserAccStatus,国家或地区名称,名字,市,Skypename,敲击,电话,状态说明,Phonecode,国籍,名字,CountryAlpha2,DeviceIdentificator) 价值观(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
我是所有这一切的新手,如果有人能帮我找到导致问题的最新信息,那就太棒了!
答案 0 :(得分:0)
消息显示您没有名为StatusDescription
的列。你确定名字是否正确?