vendredi 17 avril 2015

Android SQLite (1) no such table: viewing error

I know there are a few answers out for this issue but i still can't seem to get mine to work. i get error message;



04-17 11:35:35.086 2437-2437/com.chris.cv10aajproject E/SQLiteLog﹕ (1)
AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY
04-17 11:35:35.090 2437-2437/com.chris.cv10aajproject E/SQLiteLog﹕ (1)
no such table: viewing


my code looks like this:


i have a InsertData method in my adapter that is called by my app



public long insertData(String posCode,String firstLine ,String town,String county, int roomNum,
int askingPrice, int currentOffer, int agreedPrice, String agentName,
String agentPhone,String estateAgentNam, int refurb, String Time)
{

SQLiteDatabase db = helper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(DbHelper.POST_CODE, posCode);
contentValues.put(DbHelper.FIRST_LINE,firstLine);
contentValues.put(DbHelper.TOWN,town);
contentValues.put(DbHelper.COUNTY, county);
contentValues.put(DbHelper.ROOM_NO,roomNum);
contentValues.put(DbHelper.ASKING_PRICE,askingPrice);
contentValues.put(DbHelper.CURRENT_OFFER, currentOffer);
contentValues.put(DbHelper.AGREED_PRICE,agreedPrice);
contentValues.put(DbHelper.AGENT_NAME,agentName);
contentValues.put(DbHelper.AGENT_PHO_NUM, agentPhone);
contentValues.put(DbHelper.ESTATE_AGENT_NAME,estateAgentNam);
contentValues.put(DbHelper.REFURB_COST,refurb);
contentValues.put(DbHelper.TIME_OF_APPOINTMENT,Time);

long id = db.insert(DbHelper.TABLE_NAME, null, contentValues);
return id ;


my on create method looks like this



public void onCreate(SQLiteDatabase db) {

try {
db.execSQL(CREATE_TABLE);
Message.message(context, "onCreate called");

} catch (SQLException e) {
Message.message(context, ""+e);
}
}


and the CREATE_TABLE is a constant that looks like this:



private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + UID + "INTEGER PRIMARY KEY AUTOINCREMENT, " + POST_CODE + " VARCHAR(255)," +FIRST_LINE+" VARCHAR(255)," + TOWN + " VARCHAR(255) " +
"" + COUNTY + " VARCHAR(255) ," + ROOM_NO + " INTEGER ," + ASKING_PRICE + " INTEGER , " + CURRENT_OFFER + " INTEGER , " + AGREED_PRICE + "INTEGER , " + AGENT_NAME + " VARCHAR(255)," +
"" + AGENT_PHO_NUM + " VARCHAR(255), " + ESTATE_AGENT_NAME + " VARCHAR(255), " + REFURB_COST + " VARCHAR(255), " + TIME_OF_APPOINTMENT + " VARCHAR(255));";


Please any advice would be much appreciated


Aucun commentaire:

Enregistrer un commentaire