1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
String commentaire = newValue.toString();
if (preference.getKey().equals(MON_COM)) {
if (commentaire.equals("")) {
/*
Suppression de la ligne dans la BDD
*/
} else {
ArrayList<Locom> myListCom = new ArrayList<Locom>();
Locom myCom;
myCom = new Locom(engin, visite, commentaire);
try {
dbHelper = new CommentaireDbAdapter(ChoixDMCP.this);
dbHelper.open();
dbHelper.createEntry(myCom);
dataAdapter.notifyDataSetChanged();
} catch (Exception e) {
Toast.makeText(ChoixDMCP.this, "Erreur !\nSQLite Database !", Toast.LENGTH_LONG).show();
System.out.println("Erreur SQLite Database !");
} finally {
Toast toast = Toast.makeText(ChoixDMCP.this, "Success !\nCommentaire enregistré dans la base de donnée !", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0);
toast.show();
System.out.println("Success, commentaire enregistré dans la base de donnée !");
}
myListCom.add(myCom);
try {
String sr = dbHelper.getCommentaire(engin, visite);
Toast.makeText(ChoixDMCP.this, sr, Toast.LENGTH_LONG).show();
} catch (SQLException e) {
e.printStackTrace();
}
}
dbHelper.close();
} |
Partager