mardi 18 août 2015

Display row values in one string in android using sqlite

I've managed to get all rows of an sqlite table in android. However, I want to display all these rows in just one string. How will I do that? This is my code:

 DatabaseHandler db = new DatabaseHandler(checklist.this);
                            int cnt = db.CountMessageProduct("0");
                            Log.d("productcnt", String.valueOf(cnt));
                            List<Product> product = db.getAllProduct();


                            String b;
                                for (Product p : product) {
                                   b = p.getStorCode() + "/" + p.getCode() + 
"/" + p.getBstock() + "/" + p.getDeliveries() + "/" + p.getSpoilage() + "/" + p.getEstock() + ",";
                                    Log.d("txt",b);
                                }

Logcat

08-19 10:29:09.202  15782-15782/? D/txt﹕ TGIG/C4/2/3/4/5,
08-19 10:29:09.203  15782-15782/? D/txt﹕ RBSN/C1/12/3/3/4,
08-19 10:29:09.203  15782-15782/? D/txt﹕ MKTI/C10/23/45/67/89,
08-19 10:29:09.203  15782-15782/? D/txt﹕ RBSN/C1/12/3/4/56,
08-19 10:29:09.203  15782-15782/? D/txt﹕ TGIG/C10/46/8/9/0,

Desired Output:

TGIG/C4/2/3/4/5,RBSN/C1/12/3/3/4,MKTI/C10/23/45/67/89,RBSN/C1/12/3/4/56,TGIG/C10/46/8/9/0,

Aucun commentaire:

Enregistrer un commentaire