Demo entry 6656335

1

   

Submitted by anonymous on Oct 31, 2017 at 08:06
Language: Java. Code size: 1.8 kB.

        public List<Glasses> getDatabase(String query, String[] args, boolean useTag) {
            SQLiteDatabase db = helper.getReadableDatabase();
            Cursor cursor = db.rawQuery(query, args);

//Log.d("TAG", "DB size: "+cursor.getCount());

            items = new ArrayList<>();
            while (cursor.moveToNext()) {
                Glasses glasses = new Glasses(
                        cursor.getString(0),            // name
                        cursor.getString(1),            // price
                        cursor.getString(2),            // brand
                        cursor.getString(3),            // color
                        cursor.getString(4),            // date
                        null,                           // bitmap
                        cursor.getString(6),            // description
                        //
                        //cursor.getString(7).split(" ")// tags
                        // [태그는 검색할 때만 사용하도록 한다.]
                        null
                );

                // 비트맵 처리
                byte[] image = cursor.getBlob(5);
                //if (image != null) {
                    glasses.setBitmap(BitmapFactory.decodeByteArray(image, 0, image.length));
                //}

                // 태그 처리
                if (cursor.getString(7) != null) {
                    glasses.setTags(cursor.getString(7).split(" "));
                }
                else {
                    glasses.setTags(null);
                }

//Log.d("TAG", "MainActivity: "+glasses.getName());

                items.add(glasses);
            }
            if (useTag) {
                tag = items;
            }


            cursor.close();
            db.close();

            return items;
        }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).