vendredi 1 janvier 2016

Retriving data from Sqlite in android

Im trying to get my sqlite rows to be displayed in a alertdialog and so far it works like a charm, the only issue i have is that the result shows the newest record in the database. How could i get all records, old and New to be displayed instead of the new once?

 public void showmsg(String Title, String Message){
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setCancelable(true);
        builder.setTitle(Title);
        builder.setMessage(Message);
        builder.show();
        }

 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) {
                String selectedFromList = (String) (listView.getItemAtPosition(myItemInt));

Cursor c = dbHandler.getAll();
 while (c.moveToNext()) {
                    String sjekk = (c.getString(5));
                    if (sjekk.equals(selectedFromList)){

                        StringBuffer sf = new StringBuffer();
                        sf.append("Ovelse:  " + c.getString(1) + "\n");
                        sf.append("Set nr :  " + c.getString(2)+ "\n");
                        sf.append("Antall Rep:  " + c.getString(3)+ "\n");
                        sf.append("KG:  " + c.getString(4)+ "\n");
                        showmsg("på " + selectedFromList + "\n" + "Trente du"  ,sf.toString());


       }

Aucun commentaire:

Enregistrer un commentaire