1 package com.example.groom;
3 import android.content.ContentValues;
4 import android.content.Context;
5 import android.database.Cursor;
6 import android.database.sqlite.SQLiteDatabase;
8 import java.util.ArrayList;
14 private SQLiteDatabase
bdd;
25 List<Occupant> occupants =
new ArrayList<Occupant>();
26 Cursor cursor = bdd.query(
"occupants",
new String[] {
"idOccupant",
"nom",
"prenom",
"fonction"},
27 null, null, null, null, null, null);
30 while (!cursor.isAfterLast())
33 occupants.add(occupant);
41 public long inserer(String nom, String prenom, String fonction)
43 ContentValues values =
new ContentValues();
44 values.put(
"nom", nom);
45 values.put(
"prenom", prenom);
46 values.put(
"fonction", fonction);
48 return bdd.insert(
"occupants", null, values);
53 ContentValues values =
new ContentValues();
54 values.put(
"nom", occupant.
getNom());
55 values.put(
"prenom", occupant.
getPrenom());
58 return bdd.update(
"occupants", values,
"idOccupant = " +
id, null);
63 return bdd.delete(
"occupants",
"idOccupant = " +
id, null);
68 Cursor c = bdd.rawQuery(
"SELECT * FROM occupants WHERE nom = ?",
new String[] {nom});
75 if (c.getCount() == 0)
82 occupant.
setId(c.getInt(0));
83 occupant.
setNom(c.getString(1));
Occupant getOccupant(String nom)
List< Occupant > getListe()
Occupant cursorToServeur(Cursor c, boolean one)
void setFonction(String fonction)
Occupants(Context context)
int modifier(int id, Occupant occupant)
long inserer(String nom, String prenom, String fonction)
void setPrenom(String prenom)