Untitled
unknown
plain_text
3 years ago
2.2 kB
4
Indexable
gClass question = new gClass(); public void getQuestion(ArrayList<Integer> gler_filter, ArrayList<Integer> ller_filter) { SQLiteDatabase db = vtabani.getSqlLiteDatabase(); String[] SELECT = {"_id", "_conjunction", "_gler", "_column", "_meaning", "_sentence"}; String str_filt = "(("; for (int i = 0; i < gler_filter.size(); i++) { str_filt += "_gler=" + gler_filter.get(i); if (i != gler_filter.size() - 1) str_filt += " or "; } str_filt += ") and ("; for (int i = 0; i < ller_filter.size(); i++) { str_filt += "_ller=" + ller_filter.get(i); if (i != ller_filter.size() - 1) str_filt += " or "; } str_filt += ") and (_id NOT LIKE '" + question.id + "'))"; //Log.e("1", "1str_filt: " + str_filt); Cursor cursor = db.query("(select random() as r, * from t_gler WHERE " + str_filt + ")", SELECT, null, null, null, null, "r LIMIT 1;"); question.id = null; if (cursor.isBeforeFirst()) { while (cursor.moveToNext()) { String id = cursor.getString(cursor.getColumnIndex("_id")); String conjunction = cursor.getString(cursor.getColumnIndex("_conjunction")); String gler = cursor.getString(cursor.getColumnIndex("_gler")); String column = cursor.getString(cursor.getColumnIndex("_column")); String meaning = cursor.getString(cursor.getColumnIndex("_meaning")); String sentence = cursor.getString(cursor.getColumnIndex("_sentence")); question.setData(id, conjunction, gler, column, meaning, sentence); Log.e("question", "id: " + id); Log.e("question", "conjunction: " + conjunction); Log.e("question", "gler: " + gler); Log.e("question", "column: " + column); Log.e("question", "meaning: " + meaning); Log.e("question", "sentence: " + sentence); } } }
Editor is loading...