1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| public VerbItem[] getAllVerbs() {
final SQLiteDatabase db = MyDbHelper.getReadableDatabase();
Cursor cursor = null;
ArrayList<VerbItem> myverbs = new ArrayList<VerbItem>();
try {
cursor = db.query(MyTables.TABLE_VERBS,
VerbsQuery.PROJECTION,
null, null, null, null, null);
if (cursor.moveToFirst()) {
do {
VerbItem page = new VerbItem(
cursor.getInt(VerbsQuery.TAG_ID_VERB_COL),
cursor.getInt(VerbsQuery.TAG_ID_PAGE_COL),
cursor.getString(VerbsQuery.TAG_VERB_COL),
cursor.getString(VerbsQuery.TAG_TEMP1_COL),
cursor.getString(VerbsQuery.TAG_TEMP2_COL),
cursor.getString(VerbsQuery.TAG_TEMP3_COL),
cursor.getString(VerbsQuery.TAG_TRAD_COL),
cursor.getString(VerbsQuery.TAG_EXEMPL_COL),
cursor.getString(VerbsQuery.TAG_V_IMAG_COL),
cursor.getString(VerbsQuery.TAG_VAR1_COL));
myverbs.add(page);
} while (cursor.moveToNext());
}
VerbItem.setCount(cursor.getCount());
Log.i(TAG, "c: "+ cursor.getCount());
return myverbs.toArray(new VerbItem[myverbs.size()]);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
public interface VerbsQuery {
int _TOKEN = 0x4;
String TBN = MyTables.TABLE_VERBS;
String[] PROJECTION = {
MyTables.ID_VERB_COL,
MyTables.ID_PAGE_COL,
MyTables.VERB_COL,
MyTables.TEMP1_COL,
MyTables.TEMP2_COL,
MyTables.TEMP3_COL,
MyTables.TRAD_COL,
MyTables.EXEMPL_COL,
MyTables.V_IMAG_COL,
MyTables.VAR1_COL,
};
int TAG_ID_VERB_COL = 0;
int TAG_ID_PAGE_COL = 1;
int TAG_VERB_COL = 2;
int TAG_TEMP1_COL = 3;
int TAG_TEMP2_COL = 4;
int TAG_TEMP3_COL = 5;
int TAG_TRAD_COL = 6;
int TAG_EXEMPL_COL = 7;
int TAG_V_IMAG_COL =8;
int TAG_VAR1_COL =9;
}
} |