vendredi 26 février 2016

How to avoid special characters SQLite Android

I'm facing an issue with SQLite in Android, I know the solution must be simple, but what I have done is not working !!

 // Update a contact with a new name
    public void updatename (String phone, String newname) {
        newname = newname.replaceAll("'","\'");
        String query = "UPDATE contacts SET name = '"+newname+"' WHERE phone = '"+phone+"'";
        SQLiteDatabase db = this.getWritableDatabase();

        db.execSQL(query);

        //db.close();


    }

the replace function is not working !!

Aucun commentaire:

Enregistrer un commentaire