Note that there are some explanatory texts on larger screens.

plurals
  1. POsqlite update query error on android
    primarykey
    data
    text
    <p>when i try to update my data on sqlite this error occur </p> <pre><code>07-04 07:20:52.289: E/AndroidRuntime(2633): android.database.sqlite.SQLiteException: no such column: nick (code 1): , while compiling: UPDATE Contacts SET phone=?,nick=?,_id=?,name=? WHERE _id=2 </code></pre> <p>i didnt understand why this error is occured. i think variables dont transfer to the update query</p> <p>here is my update query</p> <pre><code>public void update(int id, String name, String phone, String nick) throws SQLException{ ContentValues cvUpdate=new ContentValues(); cvUpdate.put(KEY_ID,id); cvUpdate.put(KEY_NAME,name); cvUpdate.put(KEY_PHONE,phone); cvUpdate.put(KEY_NICK,nick); ourDatabase.update(DATABASE_TABLE, cvUpdate, KEY_ID+"="+id, null); </code></pre> <p>and i get the values from edittext andi put these values into string and int variables in mainactivity then i write this code:</p> <pre><code> info.open(); info.update(intid, contactname, contactphone, contactnick); info.close(); </code></pre> <p>this is database cretaion public class contacts_nick {</p> <pre><code>//private static final String TAG = contacts_nick.class.getSimpleName(); public static final String KEY_ID="_id"; public static final String KEY_NAME="name"; public static final String KEY_PHONE="phone"; public static final String KEY_NICK="nick"; private static final String DATABASE_NAME="mydb"; private static final String DATABASE_TABLE="Contacts"; private static final int DATABASE_VERSION=1; private DbHelper ourHelper; private final Context ourContext; private SQLiteDatabase ourDatabase; private static class DbHelper extends SQLiteOpenHelper{ public DbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); // TODO Auto-generated constructor stub } @Override //To create db public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " +DATABASE_TABLE+ " (" +KEY_ID+ " INTEGER PRIMARY KEY AUTOINCREMENT, "+KEY_NAME+" TEXT, "+KEY_PHONE+" TEXT);"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE); onCreate(db); } } public contacts_nick(Context c){ ourContext=c; } public contacts_nick open() throws SQLException{ ourHelper=new DbHelper(ourContext); ourDatabase=ourHelper.getWritableDatabase(); return this; } public contacts_nick open_read() throws SQLException{ ourHelper=new DbHelper(ourContext); ourDatabase=ourHelper.getReadableDatabase(); return this; } public void close(){ ourHelper.close(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload