IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Studio Java Discussion :

[Android Studio] Base de données


Sujet :

Android Studio Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    149
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 149
    Par défaut [Android Studio] Base de données
    Bonjour,

    je suis en train de développer une application, et j'aimerais utiliser une base de donnée pour stocker des données, je m'explique :
    Dans un layout, j'utilisateur va renseigner des champs afin de passer une commande de pot de peinture (nbr de pot, % de rouge, % de bleu et % de vert), puis appuie sur le bouton passer la commande, qui aura pour conséquence de stocker ces données dans la bdd. Dans une autre page, l'utilisateur pourrais retrouver les commandes passées qui s'afficheront dans un tableau.
    Mes questions sont donc :
    - pouvez-vous me donner une piste pour créer cette bdd, car j'ai cherché sur Internet mais je n'ai pas trouvé de tuto "simple" ? Je sais juste qu'il faut utiliser SQLite ^^
    - Pour l'affichage, est-il possible de créer n lignes dans le tableau en fonction du nombre de données entrées dans la bdd ?

    J'aimerais juste avoir quelques pistes pour mon problème ;-)

    Merci d'avance !

  2. #2
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 693
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 693
    Par défaut
    T'as pas du chercher des masses : Android database sur google te donne en premier lien la doc officiel sur le sujet :
    http://developer.android.com/trainin...databases.html

    La notion de tableau ne me semble pas adaptée à ce que tu veux faire pour l'affichage.
    Une listeview semble plus simple.
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Modérateur
    Avatar de MasterMbg
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2011
    Messages : 719
    Par défaut
    Citation Envoyé par oieretxe Voir le message
    Bonjour,

    je suis en train de développer une application, et j'aimerais utiliser une base de donnée pour stocker des données, je m'explique :
    Dans un layout, j'utilisateur va renseigner des champs afin de passer une commande de pot de peinture (nbr de pot, % de rouge, % de bleu et % de vert), puis appuie sur le bouton passer la commande, qui aura pour conséquence de stocker ces données dans la bdd. Dans une autre page, l'utilisateur pourrais retrouver les commandes passées qui s'afficheront dans un tableau.
    Mes questions sont donc :
    - pouvez-vous me donner une piste pour créer cette bdd, car j'ai cherché sur Internet mais je n'ai pas trouvé de tuto "simple" ? Je sais juste qu'il faut utiliser SQLite ^^
    - Pour l'affichage, est-il possible de créer n lignes dans le tableau en fonction du nombre de données entrées dans la bdd ?

    J'aimerais juste avoir quelques pistes pour mon problème ;-)

    Merci d'avance !
    Réponse à la question 1 : utilise SqlLite comme t'as indiqué grunk
    Réponse à la question 2 : tu peux utiliser une ListView avec un adaptateurs personnalisé ou non.
    Plus tu apprends sérieusement, plus tu te rapproches d'un savoir noble. Une chose est certaine, les difficultés ne s'écarteront de ton chemin...

    Tu es nouveau dans le développement Android, la page des COURS est là pour te faciliter la vie
    Tu peux trouver la réponse à ta question dans la FAQ
    Retrouvez mon tutoriel sur la consommation des services web SOAP
    Pense à voter positivement en appuyant sur en bas à droite de la réponse qui t'a donné une piste de solution.

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    149
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 149
    Par défaut
    Bonjour,

    j'ai avancé sur la création de ma bdd, mais j'aimerais avoir votre avis sur ce que j'ai déjà fait, car je ne sais pas si je suis sur la bonne voie. J'ai suivi un tuto trouvé sur un autre site.

    J'ai créé 3 classes, la première est la classe Commande :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    public class Commande {
     
        private int id;
        private String date;
        private String heure;
        private int pourcentage_rouge;
        private int pourcentage_vert;
        private int pourcentage_bleu;
     
        public Commande(){}
     
        public Commande(String date, String heure, int pourcentage_rouge, int pourcentage_vert, int pourcentage_bleu){
            this.date = date;
            this.heure = heure;
            this.pourcentage_rouge = pourcentage_rouge;
            this.pourcentage_vert = pourcentage_vert;
            this.pourcentage_bleu = pourcentage_bleu;
        }
     
        public int getId() {
            return id;
        }
     
        public void setId(int id) {
            this.id = id;
        }
     
        public String getDate() {
            return date;
        }
     
        public void setDate(String date) {
            this.date = date;
        }
     
        public String getHeure() {
            return heure;
        }
     
        public void setHeure(String heure) {
            this.heure = heure;
        }
     
        public int getPourcentage_rouge() {
            return pourcentage_rouge;
        }
     
        public void setPoucentage_rouge(int pourcentage_rouge) {
            this.pourcentage_rouge = pourcentage_rouge;
        }
     
        public int getPourcentage_vert() {
            return pourcentage_vert;
        }
     
        public void setPourcentage_vert(int pourcentage_vert) {
            this.pourcentage_vert = pourcentage_vert;
        }
     
        public int getPourcentage_bleu() {
            return pourcentage_bleu;
        }
     
        public void setPourcentage_bleu(int pourcentage_bleu) {
            this.pourcentage_bleu = pourcentage_bleu;
        }
     
    }
    Ensuite la classe CommandesBDD :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
     
    public class CommandesBDD {
     
        private static final int VERSION_BDD = 1;
        private static final String NOM_BDD = "eleves.db";
     
        private static final String TABLE_COMMANDES = "table_commandes";
        private static final String COL_ID = "ID";
        private static final int NUM_COL_ID = 0;
        private static final String COL_DATE = "Date";
        private static final int NUM_COL_ISBN = 1;
        private static final String COL_HEURE = "Heure";
        private static final int NUM_COL_TITRE = 2;
        private static final String COL_POURCENTAGE_ROUGE = "% Rouge";
        private static final int NUM_COL_POURCENTAGE_ROUGE = 3;
        private static final String COL_POURCENTAGE_BLEU = "% Bleu";
        private static final int NUM_COL_POURCENTAGE_BLEU = 4;
        private static final String COL_POURCENTAGE_VERT = "% Vert";
        private static final int NUM_COL_POURCENTAGE_VERT = 5;
     
        private SQLiteDatabase bdd;
     
        private MaBaseSQLite maBaseSQLite;
     
        public CommandesBDD(Context context){
            //On créer la BDD et sa table
            maBaseSQLite = new MaBaseSQLite(context, NOM_BDD, null, VERSION_BDD);
        }
     
        public void open(){
            //on ouvre la BDD en écriture
            bdd = maBaseSQLite.getWritableDatabase();
        }
     
        public void close(){
            //on ferme l'accès à la BDD
            bdd.close();
        }
     
        public SQLiteDatabase getBDD(){
            return bdd;
        }
     
        public long insertCommande(Commande Commande){
            //Création d'un ContentValues (fonctionne comme une HashMap)
            ContentValues values = new ContentValues();
            //on lui ajoute une valeur associé à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
            values.put(COL_DATE, Commande.getDate());
            values.put(COL_HEURE, Commande.getHeure());
            values.put(COL_POURCENTAGE_ROUGE, Commande.getPourcentage_rouge());
            values.put(COL_POURCENTAGE_BLEU, Commande.getPourcentage_bleu());
            values.put(COL_POURCENTAGE_VERT, Commande.getPourcentage_vert());
            //on insère l'objet dans la BDD via le ContentValues
            return bdd.insert(TABLE_COMMANDES, null, values);
        }
     
        public int updateCommande(int id, Commande Commande){
            //La mise à jour d'une commande dans la BDD fonctionne plus ou moins comme une insertion
            //il faut simple préciser quelle livre on doit mettre à jour grâce à l'ID
            ContentValues values = new ContentValues();
            values.put(COL_DATE, Commande.getDate());
            values.put(COL_HEURE, Commande.getHeure());
            values.put(COL_POURCENTAGE_ROUGE, Commande.getPourcentage_rouge());
            values.put(COL_POURCENTAGE_BLEU, Commande.getPourcentage_bleu());
            values.put(COL_POURCENTAGE_VERT, Commande.getPourcentage_vert());
            return bdd.update(TABLE_COMMANDES, values, COL_ID + " = " +id, null);
        }
     
        public int removeCommandeWithID(int id){
            //Suppression d'une commande de la BDD grâce à l'ID
            return bdd.delete(TABLE_COMMANDES, COL_ID + " = " +id, null);
        }
     
    }
    Et enfin la classe MaBaseSQLite :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.database.sqlite.SQLiteDatabase.CursorFactory;
     
    public class MaBaseSQLite extends SQLiteOpenHelper {
     
        private static final String TABLE_COMMANDES = "table_commandes";
        private static final String COL_ID = "ID";
        private static final String COL_DATE = "Date";
        private static final String COL_HEURE = "Heure";
        private static final String COL_POURCENTAGE_ROUGE = "Rouge";
        private static final String COL_POURCENTAGE_VERT = "Vert";
        private static final String COL_POURCENTAGE_BLEU = "Bleu";
     
        private static final String CREATE_BDD = "CREATE TABLE " + TABLE_COMMANDES + " ("
                + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_DATE + " TEXT NOT NULL, "
                + COL_HEURE + " TEXT NOT NULL, " + COL_POURCENTAGE_ROUGE + " TEXT NOT NULL, "
                + COL_POURCENTAGE_VERT + " TEXT NOT NULL, " + COL_POURCENTAGE_BLEU + " TEXT NOT NULL);";
     
        public MaBaseSQLite(Context context, String name, CursorFactory factory, int version) {
            super(context, name, factory, version);
        }
     
        @Override
        public void onCreate(SQLiteDatabase db) {
            //on créé la table à partir de la requête écrite dans la variable CREATE_BDD
            db.execSQL(CREATE_BDD);
        }
     
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            //On peut fait ce qu'on veut ici moi j'ai décidé de supprimer la table et de la recréer
            //comme ça lorsque je change la version les id repartent de 0
            db.execSQL("DROP TABLE " + TABLE_COMMANDES + ";");
            onCreate(db);
        }
    J'ai ensuite un layout Commander :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/fond"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.wamove.Commander" >
     
        <Button
            android:id="@+id/button"
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:background="@drawable/button_state"
            android:onClick="open_historique"
            android:text="@string/historique"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />
        <Button
            android:id="@+id/button2"
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:background="@drawable/button_state"
            android:text="@string/passer_la_commande"
            android:layout_alignParentRight="true"
            android:onClick="enregistrer_commande"
            android:layout_alignParentBottom="true" />
     
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:gravity="center"
            android:layout_above="@+id/button">
     
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/passez_commande"
                android:id="@+id/textView"
                android:layout_gravity="center_horizontal"
                android:gravity="center"
                android:textStyle="bold|italic"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp" />
     
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/layout"
                android:background="@drawable/layout_border"
                android:gravity="left"
                android:paddingTop="15dp"
                android:paddingBottom="15dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp">
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/ndr_de_pots"
                        android:id="@+id/textView6"
                        android:textSize="25sp"
                        android:layout_marginRight="5dp"
                        android:gravity="right" />
     
                    <EditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/nbr_pots"
                        android:layout_gravity="center_horizontal"
                        android:hint="@string/max_pots"
                        android:gravity="center"
                        android:padding="0dp" />
                </LinearLayout>
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:layout_marginTop="20dp">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/pourc_rouge"
                        android:id="@+id/textView8"
                        android:textSize="25sp"
                        android:layout_marginRight="5dp"
                        android:gravity="right" />
     
                    <EditText
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/pourcentage_rouge"
                        android:gravity="center" />
                </LinearLayout>
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/pourc_bleu"
                        android:id="@+id/textView9"
                        android:textSize="25sp"
                        android:gravity="right"
                        android:layout_marginRight="5dp" />
     
                    <EditText
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/pourcentage_bleu"
                        android:gravity="center" />
                </LinearLayout>
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/pourc_vert"
                        android:id="@+id/textView10"
                        android:textSize="25sp"
                        android:layout_marginRight="5dp"
                        android:gravity="right" />
     
                    <EditText
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/pourcentage_vert"
                        android:gravity="center" />
                </LinearLayout>
     
            </LinearLayout>
        </LinearLayout>
     
    </RelativeLayout>
    Avec son code Java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    package com.example.wamove;
     
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;
    import java.util.Calendar;
     
     
     
     
     
     
    public class Commander extends Activity {
     
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_commander);
     
     
        }
     
        public void open_historique(View v){
            Intent open_historique=new Intent(Commander.this,Historique.class);
            startActivity(open_historique);
            Commander.this.finish();
        }
     
        public boolean onKeyDown(int keyCode, KeyEvent event)
        {
            //replaces the default 'Back' button action
            if(keyCode==KeyEvent.KEYCODE_BACK)
            {
                Intent open_accueil=new Intent(Commander.this,Accueil.class);
                startActivity(open_accueil);
                Commander.this.finish();
            }
            return true;
        }
     
        public void enregistrer_commande(View v){
     
            EditText nbr_pots = (EditText) findViewById(R.id.nbr_pots);
            EditText edit_pourcentage_rouge = (EditText) findViewById(R.id.pourcentage_rouge);
            EditText edit_pourcentage_vert = (EditText) findViewById(R.id.pourcentage_vert);
            EditText edit_pourcentage_bleu = (EditText) findViewById(R.id.pourcentage_bleu);
     
            if (nbr_pots.getText().toString().trim().isEmpty() || edit_pourcentage_rouge.getText().toString().trim().isEmpty() ||
                    edit_pourcentage_vert.getText().toString().trim().isEmpty() || edit_pourcentage_bleu.getText().toString().trim().isEmpty())
            {
                Toast.makeText(getApplicationContext(), "Veuillez renseigner tous les champs !",Toast.LENGTH_SHORT).show();
            }
            else
            {
                int valrouge = (int) Integer.parseInt(edit_pourcentage_rouge.getText().toString());
                int valbleu = (int) Integer.parseInt(edit_pourcentage_bleu.getText().toString());
                int valvert = (int) Integer.parseInt(edit_pourcentage_vert.getText().toString());
                if((valrouge+valbleu+valvert)!=(int)100)
                {
                    Toast.makeText(getApplicationContext(), "Le total doit être de 100% !",Toast.LENGTH_SHORT).show();
                }
                else
                {
                    //Création d'une instance de ma classe CommandesBDD
                    CommandesBDD commandesBdd = new CommandesBDD(this);
     
                    //Création d'une commande
                    Commande commande = new Commande(String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)), String.valueOf(Calendar.getInstance().get(Calendar.DATE)),
                            valrouge, valvert, valbleu);
     
                    //On ouvre la base de données pour écrire dedans
                    commandesBdd.open();
     
                    //Toast.makeText(getApplicationContext(), "OK",Toast.LENGTH_SHORT).show();
     
                    //On insère la commande que l'on vient de créer
                    commandesBdd.insertCommande(commande);
     
                    commandesBdd.close();
     
     
     
                }
            }
     
        }
    }
    Donc, lorsque je renseigne bien tous les champs, et que la somme des 3 % vaut 100, je travaille sur la Bdd. Je n'ai aucune erreur lors de l'exécution de mon code, mais j'aimerais avoir un moyen de vérifier le contenu de ma Bdd.

    Merci d'avance !

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    149
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 149
    Par défaut
    J'ai réalisé des mis à jours de mon code.
    Commande.java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    package com.example.wamove;
     
    /**
     * Created by Oier on 10/01/2015.
     */
    public class Commande {
     
        private int id;
        private String date;
        private String heure;
        private int nbr_pots;
        private int pourcentage_rouge;
        private int pourcentage_vert;
        private int pourcentage_bleu;
     
        public Commande(){}
     
        public Commande(String date, String heure,int nbr_pots, int pourcentage_rouge, int pourcentage_vert, int pourcentage_bleu){
            this.date = date;
            this.heure = heure;
            this.nbr_pots = nbr_pots;
            this.pourcentage_rouge = pourcentage_rouge;
            this.pourcentage_vert = pourcentage_vert;
            this.pourcentage_bleu = pourcentage_bleu;
        }
     
        public int getId() {
            return id;
        }
     
        public void setId(int id) {
            this.id = id;
        }
     
        public String getDate() {
            return date;
        }
     
        public void setDate(String date) {
            this.date = date;
        }
     
        public String getHeure() {
            return heure;
        }
     
        public void setHeure(String heure) {
            this.heure = heure;
        }
     
        public int getNbr_pots() {
            return nbr_pots;
        }
     
        public void setNbr_pots(int nbr_pots) {
            this.nbr_pots = nbr_pots;
        }
     
        public int getPourcentage_rouge() {
            return pourcentage_rouge;
        }
     
        public void setPoucentage_rouge(int pourcentage_rouge) {
            this.pourcentage_rouge = pourcentage_rouge;
        }
     
        public int getPourcentage_vert() {
            return pourcentage_vert;
        }
     
        public void setPourcentage_vert(int pourcentage_vert) {
            this.pourcentage_vert = pourcentage_vert;
        }
     
        public int getPourcentage_bleu() {
            return pourcentage_bleu;
        }
     
        public void setPourcentage_bleu(int pourcentage_bleu) {
            this.pourcentage_bleu = pourcentage_bleu;
        }
     
    }
    CommandesBDD.java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    package com.example.wamove; /**
     * Created by Oier on 10/01/2015.
     */
     
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
     
    public class CommandesBDD {
     
        private static final int VERSION_BDD = 1;
        private static final String NOM_BDD = "commandes.db";
     
        private static final String TABLE_COMMANDES = "table_commandes";
        private static final String COL_ID = "ID";
        private static final int NUM_COL_ID = 0;
        private static final String COL_DATE = "Date";
        private static final int NUM_COL_DATE = 1;
        private static final String COL_HEURE = "Heure";
        private static final int NUM_COL_HEURE = 2;
        private static final String COL_NBR_POTS = "Nbr_pots";
        private static final int NUM_COL_NBR_POTS = 3;
        private static final String COL_POURCENTAGE_ROUGE = "Rouge";
        private static final int NUM_COL_POURCENTAGE_ROUGE = 4;
        private static final String COL_POURCENTAGE_BLEU = "Bleu";
        private static final int NUM_COL_POURCENTAGE_BLEU = 5;
        private static final String COL_POURCENTAGE_VERT = "Vert";
        private static final int NUM_COL_POURCENTAGE_VERT = 6;
     
        private SQLiteDatabase bdd;
     
        private MaBaseSQLite maBaseSQLite;
     
        public CommandesBDD(Context context){
            //On créer la BDD et sa table
            maBaseSQLite = new MaBaseSQLite(context, NOM_BDD, null, VERSION_BDD);
        }
     
        public void open(){
            //on ouvre la BDD en écriture
            bdd = maBaseSQLite.getWritableDatabase();
        }
     
        public void close(){
            //on ferme l'accès à la BDD
            bdd.close();
        }
     
        public SQLiteDatabase getBDD(){
            return bdd;
        }
     
        public long insertCommande(Commande Commande){
            //Création d'un ContentValues (fonctionne comme une HashMap)
            ContentValues values = new ContentValues();
            //on lui ajoute une valeur associé à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
            values.put(COL_DATE, Commande.getDate());
            values.put(COL_HEURE, Commande.getHeure());
            values.put(COL_NBR_POTS, Commande.getNbr_pots());
            values.put(COL_POURCENTAGE_ROUGE, Commande.getPourcentage_rouge());
            values.put(COL_POURCENTAGE_BLEU, Commande.getPourcentage_bleu());
            values.put(COL_POURCENTAGE_VERT, Commande.getPourcentage_vert());
            //on insère l'objet dans la BDD via le ContentValues
            return bdd.insert(TABLE_COMMANDES, null, values);
        }
     
        public int updateCommande(int id, Commande Commande){
            //La mise à jour d'une commande dans la BDD fonctionne plus ou moins comme une insertion
            //il faut simple préciser quelle livre on doit mettre à jour grâce à l'ID
            ContentValues values = new ContentValues();
            values.put(COL_DATE, Commande.getDate());
            values.put(COL_HEURE, Commande.getHeure());
            values.put(COL_NBR_POTS, Commande.getNbr_pots());
            values.put(COL_POURCENTAGE_ROUGE, Commande.getPourcentage_rouge());
            values.put(COL_POURCENTAGE_BLEU, Commande.getPourcentage_bleu());
            values.put(COL_POURCENTAGE_VERT, Commande.getPourcentage_vert());
            return bdd.update(TABLE_COMMANDES, values, COL_ID + " = " +id, null);
        }
     
        public int removeCommandeWithID(int id){
            //Suppression d'une commande de la BDD grâce à l'ID
            return bdd.delete(TABLE_COMMANDES, COL_ID + " = " +id, null);
        }
     
        //Cette méthode permet de convertir un cursor en une commande
        private Commande cursorToLivre(Cursor c){
            //si aucun élément n'a été retourné dans la requête, on renvoie null
            if (c.getCount() == 0)
                return null;
     
            //Sinon on se place sur le premier élément
            c.moveToFirst();
            //On créé une commande
            Commande commande = new Commande();
            //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor
            commande.setId(c.getInt(NUM_COL_ID));
            commande.setDate(c.getString(NUM_COL_DATE));
            commande.setHeure(c.getString(NUM_COL_HEURE));
            commande.setNbr_pots(c.getInt(NUM_COL_NBR_POTS));
            commande.setPoucentage_rouge(c.getInt(NUM_COL_POURCENTAGE_ROUGE));
            commande.setPourcentage_bleu(c.getInt(NUM_COL_POURCENTAGE_BLEU));
            commande.setPourcentage_vert(c.getInt(NUM_COL_POURCENTAGE_VERT));
            //On ferme le cursor
            c.close();
     
            //On retourne la commande
            return commande;
        }
     
    }
    MaBaseSQLite.java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    package com.example.wamove; /**
     * Created by Oier on 10/01/2015.
     */
     
    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteDatabase.CursorFactory;
    import android.database.sqlite.SQLiteOpenHelper;
     
    public class MaBaseSQLite extends SQLiteOpenHelper {
     
        private static final String TABLE_COMMANDES = "table_commandes";
        private static final String COL_ID = "ID";
        private static final String COL_DATE = "Date";
        private static final String COL_HEURE = "Heure";
        private static final String COL_NBR_POTS = "Nbr_pots";
        private static final String COL_POURCENTAGE_ROUGE = "Rouge";
        private static final String COL_POURCENTAGE_VERT = "Vert";
        private static final String COL_POURCENTAGE_BLEU = "Bleu";
     
        private static final String CREATE_BDD = "CREATE TABLE " + TABLE_COMMANDES + " ("
                + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_DATE + " TEXT NOT NULL, "
                + COL_HEURE + " TEXT NOT NULL, " + COL_NBR_POTS + " TEXT NOT NULL, " + COL_POURCENTAGE_ROUGE
                + " TEXT NOT NULL, " + COL_POURCENTAGE_VERT + " TEXT NOT NULL, " + COL_POURCENTAGE_BLEU + " TEXT NOT NULL);";
     
        public MaBaseSQLite(Context context, String name, CursorFactory factory, int version) {
            super(context, name, factory, version);
        }
     
        @Override
        public void onCreate(SQLiteDatabase db) {
            //on créé la table à partir de la requête écrite dans la variable CREATE_BDD
            db.execSQL(CREATE_BDD);
        }
     
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            //On peut fait ce qu'on veut ici moi j'ai décidé de supprimer la table et de la recréer
            //comme ça lorsque je change la version les id repartent de 0
            db.execSQL("DROP TABLE " + TABLE_COMMANDES + ";");
            onCreate(db);
        }
     
    }
    Layout Commander:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/fond"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.wamove.Commander" >
     
        <Button
            android:id="@+id/button"
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:background="@drawable/button_state"
            android:onClick="open_historique"
            android:text="@string/historique"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />
        <Button
            android:id="@+id/button2"
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:background="@drawable/button_state"
            android:text="@string/passer_la_commande"
            android:layout_alignParentRight="true"
            android:onClick="enregistrer_commande"
            android:layout_alignParentBottom="true" />
     
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:gravity="center"
            android:layout_above="@+id/button">
     
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/passez_commande"
                android:id="@+id/textView"
                android:layout_gravity="center_horizontal"
                android:gravity="center"
                android:textStyle="bold|italic"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp" />
     
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/layout"
                android:background="@drawable/layout_border"
                android:gravity="left"
                android:paddingTop="15dp"
                android:paddingBottom="15dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp">
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/ndr_de_pots"
                        android:id="@+id/textView6"
                        android:textSize="25sp"
                        android:layout_marginRight="5dp"
                        android:gravity="right" />
     
                    <EditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/nbr_pots"
                        android:layout_gravity="center_horizontal"
                        android:hint="@string/max_pots"
                        android:gravity="center"
                        android:padding="0dp" />
                </LinearLayout>
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:layout_marginTop="20dp">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/pourc_rouge"
                        android:id="@+id/textView8"
                        android:textSize="25sp"
                        android:layout_marginRight="5dp"
                        android:gravity="right" />
     
                    <EditText
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/pourcentage_rouge"
                        android:gravity="center" />
                </LinearLayout>
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/pourc_bleu"
                        android:id="@+id/textView9"
                        android:textSize="25sp"
                        android:gravity="right"
                        android:layout_marginRight="5dp" />
     
                    <EditText
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/pourcentage_bleu"
                        android:gravity="center" />
                </LinearLayout>
     
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center">
     
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:text="@string/pourc_vert"
                        android:id="@+id/textView10"
                        android:textSize="25sp"
                        android:layout_marginRight="5dp"
                        android:gravity="right" />
     
                    <EditText
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/pourcentage_vert"
                        android:gravity="center" />
                </LinearLayout>
     
            </LinearLayout>
        </LinearLayout>
     
    </RelativeLayout>
    Commander.java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    package com.example.wamove;
     
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;
     
    import java.util.Calendar;
     
    public class Commander extends Activity {
     
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_commander);
     
     
        }
     
        public void open_historique(View v){
            Intent open_historique=new Intent(Commander.this,Historique.class);
            startActivity(open_historique);
            Commander.this.finish();
        }
     
        public boolean onKeyDown(int keyCode, KeyEvent event)
        {
            //replaces the default 'Back' button action
            if(keyCode==KeyEvent.KEYCODE_BACK)
            {
                Intent open_accueil=new Intent(Commander.this,Accueil.class);
                startActivity(open_accueil);
                Commander.this.finish();
            }
            return true;
        }
     
        public void enregistrer_commande(View v){
     
            EditText nbr_pots = (EditText) findViewById(R.id.nbr_pots);
            EditText edit_pourcentage_rouge = (EditText) findViewById(R.id.pourcentage_rouge);
            EditText edit_pourcentage_vert = (EditText) findViewById(R.id.pourcentage_vert);
            EditText edit_pourcentage_bleu = (EditText) findViewById(R.id.pourcentage_bleu);
     
            if (nbr_pots.getText().toString().trim().isEmpty() || edit_pourcentage_rouge.getText().toString().trim().isEmpty() ||
                    edit_pourcentage_vert.getText().toString().trim().isEmpty() || edit_pourcentage_bleu.getText().toString().trim().isEmpty())
            {
                Toast.makeText(getApplicationContext(), "Veuillez renseigner tous les champs !",Toast.LENGTH_SHORT).show();
            }
            else
            {
                int nbrpots = (int) Integer.parseInt(nbr_pots.getText().toString());
                int valrouge = (int) Integer.parseInt(edit_pourcentage_rouge.getText().toString());
                int valbleu = (int) Integer.parseInt(edit_pourcentage_bleu.getText().toString());
                int valvert = (int) Integer.parseInt(edit_pourcentage_vert.getText().toString());
     
                if( nbrpots > (int) 20)
                {
                    Toast.makeText(getApplicationContext(), "20 pots maximum !", Toast.LENGTH_SHORT).show();
                }
                else if (nbrpots==0)
                {
                    Toast.makeText(getApplicationContext(), "Au moins 1 pot !", Toast.LENGTH_SHORT).show();
                }
                else {
                    if ((valrouge + valbleu + valvert) != 100)
                    {
                        Toast.makeText(getApplicationContext(), "Le total doit être de 100% !", Toast.LENGTH_SHORT).show();
                    }
                    else {
                        //Création d'une instance de ma classe CommandesBDD
                        CommandesBDD commandesBdd = new CommandesBDD(this);
     
                        //Création d'une commande
                        Commande commande = new Commande( String.valueOf(Calendar.getInstance().get(Calendar.DATE)+"/"+Calendar.getInstance().get(Calendar.MONTH)+"/"+Calendar.getInstance().get(Calendar.YEAR)),String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)+":"+Calendar.getInstance().get(Calendar.MINUTE)),
                                nbrpots, valrouge, valvert, valbleu);
     
                        //On ouvre la base de données pour écrire dedans
                        commandesBdd.open();
     
                        //Toast.makeText(getApplicationContext(), "OK",Toast.LENGTH_SHORT).show();
     
                        //On insère la commande que l'on vient de créer
                        commandesBdd.insertCommande(commande);
     
                        commandesBdd.close();
     
                        Toast.makeText(getApplicationContext(), "Commande enregistrée", Toast.LENGTH_SHORT).show();
     
                        Intent open_accueil=new Intent(Commander.this,Accueil.class);
                        startActivity(open_accueil);
                        Commander.this.finish();
                    }
                }
            }
     
        }
    }

  6. #6
    Modérateur
    Avatar de MasterMbg
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2011
    Messages : 719
    Par défaut
    Bonjour,
    Pour la classe Commande.java, rien de grave à signaler;
    Seulement pour les deux autres classes à savoir CommandesBDD.java (classe d'accès aux données) et MaBaseSQLite.java (Classe de gestion de la base de données (création de la base, des tables, mise à jour de la structure des tables...)) il y a un tout petit peu de redondances dans les déclarations des champs.
    Ces attributs de la classe MaBaseSQLite.java suffiraient pour être appelés dans la classe CommandesBDD.java pour raison de manipulations de la table des commandes du fait qu'ils soient déclarés static:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    private static final String TABLE_COMMANDES = "table_commandes";
        private static final String COL_ID = "ID";
        private static final String COL_DATE = "Date";
        private static final String COL_HEURE = "Heure";
        private static final String COL_NBR_POTS = "Nbr_pots";
        private static final String COL_POURCENTAGE_ROUGE = "Rouge";
        private static final String COL_POURCENTAGE_VERT = "Vert";
        private static final String COL_POURCENTAGE_BLEU = "Bleu";

    Sinon, tu es dans la logique je peux dire sauf que tu n'as pas géré les cas d'exceptions (try); Exécute d'abord est fais signe.
    Plus tu apprends sérieusement, plus tu te rapproches d'un savoir noble. Une chose est certaine, les difficultés ne s'écarteront de ton chemin...

    Tu es nouveau dans le développement Android, la page des COURS est là pour te faciliter la vie
    Tu peux trouver la réponse à ta question dans la FAQ
    Retrouvez mon tutoriel sur la consommation des services web SOAP
    Pense à voter positivement en appuyant sur en bas à droite de la réponse qui t'a donné une piste de solution.

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    149
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 149
    Par défaut
    Tout d'abord merci beaucoup pour ta réponse.

    Concernant la déclaration des champs, je vois bien qu'il y a de la redondance, mais comment y pallier ?
    Sinon question bête mais lorsque j'appuie la première fois sur le bouton, les données sont bien enregistrées, mais si j'appuie une deuxième fois, les premières données ne sont pas supprimées au moins ? En gros est-ce que le code que j'ai est correct dans l'ensemble ? Comment pourrais-je, par exemple, récupérer le nombre d'éléments présents dans la bdd afin de l'afficher via un Toast.

    Je suis aussi en train de voir pour afficher le contenu de ma bdd dans une ListView suite à ton conseil, mais pour cela il faut que je trouve les requêtes à effectuer afin de récupérer les données, c'est bien ça ?

    Merci beaucoup en tout cas

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 02/02/2014, 22h17
  2. [Débutant] connexion Visual studio base de données odbc
    Par IAGISG dans le forum VB.NET
    Réponses: 1
    Dernier message: 29/08/2011, 16h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo