android - error loadind data from sqlite to spinner -


while loading data sqlite spinner data repeated several times, values "traditionnel" , "fast food" repeated several times

    @override     protected void oncreate(bundle savedinstancestate) {                  contentvalues values = new contentvalues();                values.put(column_categoriename , "fast food");                db.insert(table_categorie, null, values);                values.put(column_categoriename , "traditionnel");                db.insert(table_categorie, null, values);                 db.insert(table_categorie, null, values);                cursor c = db.query(table_categorie,  new string[] { column_idcategorie, column_categoriename}   , null,null,null,null,null);               int col=c.getcount();                          if (col == 0) {                         toast.maketext(mainactivity.this, "pas de donnees ", toast.length_long).show();                         // effacer le contenue champ login et mot de passe                          }                     else {                         // col =1  il ya un utilisateur qui verifie la condition                         c.movetofirst();                            while (c.isafterlast() == false) {                                // conversion int string casting                                 string ch1=""+c.getint(0);                                 string ch2=c.getstring(1);                                adapter.add(ch2);                                 c.movetonext();                             }                     }                        c.close();                          spinner s = (spinner) findviewbyid(r.id.spinner1);                     s.setadapter(adapter);   


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -