Skip to content Skip to sidebar Skip to footer

Unable To Insert Data In Sqlite Database Android

Following code is used to insert data in the database. When application is launched, following code is executed. After RecentDBManager is executed, when I PULL database from emula

Solution 1:

try

@OverridepublicvoidonCreate(SQLiteDatabase db) {
    db.execSQL(Create table Memo(ID INTEGER PRIMARY KEY AUTOINCREMENT, sym TEXT, cmp TEXT, cng TEXT);
}

.

publicvoidsetData(String value1, String value2, String value3) {

            ContentValues cv = newContentValues();
            cv.put("sym", value1);
            cv.put("cmp", value2);
            cv.put("cng", value3);

            mDb.insert(TABLE_NAME, null, cv);
    }        

Solution 2:

Try leaving a blank space after tablename of your insert statement:

insertinto FavoriteScrip (sym,cmp,chg) values ('value1','value2','value3')

InsertStmt="insert into " + TABLE_NAME + " (sym,cmp,chg) values ('" + value1 + "','" + value2                    + "','" + value3 + "')";

Solution 3:

try using insert instead of raw query

Post a Comment for "Unable To Insert Data In Sqlite Database Android"