Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
941 B
1
Indexable
Never
    public Vector<AddressBook> getAddressBook() {
        SQLiteDatabase db = this.getWritableDatabase();
        Vector<AddressBook> addressBooks = new Vector<>();
        String query = "SELECT * FROM " + TABLE_NAME;
        Cursor cursor = db.rawQuery(query, null);
        if (cursor.moveToFirst()) {
            do {
                AddressBook addressBook = new AddressBook(
                        cursor.getInt(0),
                        cursor.getString(1),
                        cursor.getString(2),
                        cursor.getString(3),
                        cursor.getString(4),
                        cursor.getString(5),
                        cursor.getString(6),
                        cursor.getString(7)
                );

                addressBooks.add(addressBook);
            } while (cursor.moveToNext());
            return addressBooks;
        }

        return null;
    }