سلام
علت اجرا نشدن کوری دیلیت داخل این کد چیه؟؟
قبلن ممنون
علت اجرا نشدن کوری دیلیت داخل این کد چیه؟؟
public class Dataman extends SQLiteOpenHelper { public Dataman(Context context) { super(context, "mydb", null, 1); } @Override public void onCreate(SQLiteDatabase db) { String q = " CREATE TABLE ST(" + " name VARCHAR (50)" + ");"; db.execSQL(q); } @Override public void onUpgrade(SQLiteDatabase db, int i, int i1) { db.execSQL("DROP TABLE IF EXISTS ST"); onCreate(db); } public boolean addfav(String name) { boolean result; try { String q = "INSERT INTO ST(name)" + " VALUES (' " + name + " ')"; SQLiteDatabase db = this.getWritableDatabase(); db.execSQL(q); db.close(); result = true; } catch (Exception e) { result = false; } return result; } /* public boolean upstudent(student student){ boolean result; try { String q = "UPDATE ST" + "SET name='"+student.name+"'" + "WHERE id=4"; SQLiteDatabase db = this.getWritableDatabase(); db.execSQL(q); db.close(); result = true; } catch (Exception e){ result =false; } return result; }*/ public List<String> getfav() { // favor favor = new favor(); List<String> all=new ArrayList<>(); try { String q = "SELECT * FROM ST " ; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(q, null); while (cursor.moveToNext()) { String name=cursor.getString(cursor.getColumnIndex("name")); all.add(name); // favor.name = cursor.getString(1); } db.close(); cursor.close(); } catch (Exception e) { } return all; } public boolean delfav(String name) { boolean result; try { String q = "DELETE FROM ST WHERE name= '"+ name+"'"; SQLiteDatabase db = this.getWritableDatabase(); db.execSQL(q); db.close(); result = true; } catch (Exception ex) { result = false; } return result; } }
قبلن ممنون