Erum
Erum

Reputation: 790

Failed to Insert Data in SQLITE DataBase using Java in Android?

i am newbie in android here is the table :

    private static final String parameterString = "CREATE TABLE IF NOT EXISTS parameterTable(ID INTEGER PRIMARY KEY AUTOINCREMENT,param_type TEXT,cash_code TEXT,param_description TEXT)";
dataBaseAdapterInstance = new DataBaseAdapter(context);
       @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(parameterString);
    }
private void setHardCodedSpinnerValue()
{
dataBaseAdapterInstance.openToWrite();
final String endUserContractorArray[] = {"End User -With Risk Assessment","End User -Without Risk Assessment", "Contractor" };

String query =  "INSERT  INTO parameterTable(ID,param_type,cash_code,param_description) " +
 "VALUES ('331','"+endUserContractorArray[0]+"','"EUWRA"','"End User With Risk Assessment"');";
dataBaseAdapterInstance.getDatabaseInstance().execSQL(query);
}

I am getting error on this line

String query =  "INSERT  INTO parameterTable(ID,param_type,cash_code,param_description) " +
 "VALUES ('331','"+endUserContractorArray[0]+"','"EUWRA"','"End User With Risk Assessment"');";

These are the hardcode values EUWRA"','"End User With Risk Assessment"'
dataBaseAdapterInstance has already declared.The error is when i am trying to insert hardcoded Values.Please help me what am i doing wrong ?

Upvotes: 0

Views: 729

Answers (1)

Ketan Ahir
Ketan Ahir

Reputation: 6738

try this way From here

 String query =  "INSERT  INTO parameterTable(ID,param_type,cash_code,param_description) " +
             "VALUES ('331','"+endUserContractorArray[0]+"','EUWRA','End User With Risk Assessment');";

Upvotes: 2

Related Questions