List of usage examples for android.database Cursor isAfterLast
boolean isAfterLast();
From source file:com.rener.sea.DBHelper.java
public List<Flowchart> getAllFlowcharts() { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_FLOWCHART, new String[] { DBSchema.FLOWCHART_ID }, DBSchema.STATUS + " =? ", new String[] { String.valueOf(1) }, null, null, DBSchema.FLOWCHART_NAME + " COLLATE NOCASE", null); ArrayList<Flowchart> flowcharts; flowcharts = new ArrayList<>(); if ((cursor != null) && (cursor.getCount() > 0)) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { flowcharts.add(new Flowchart(cursor.getLong(0), this)); }/*from w w w .j a va 2s. c o m*/ db.close(); cursor.close(); } return flowcharts; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getLocation_category() { JSONArray data;/* w w w.ja v a2s . c om*/ data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_LOCATION_CATEGORY, new String[] { DBSchema.LOCATION_CATEGORY_LOCATION_ID, DBSchema.LOCATION_CATEGORY_CATEGORY_ID }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0)) map.put(DBSchema.LOCATION_CATEGORY_LOCATION_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1)) map.put(DBSchema.LOCATION_CATEGORY_CATEGORY_ID, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getItem() { JSONArray data;//from ww w. j av a 2s . co m data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_ITEM, new String[] { DBSchema.ITEM_ID, DBSchema.ITEM_FLOWCHART_ID, DBSchema.ITEM_LABEL, DBSchema.ITEM_TYPE }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0)) map.put(DBSchema.ITEM_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1)) map.put(DBSchema.ITEM_FLOWCHART_ID, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(2)) map.put(DBSchema.ITEM_LABEL, cursor.getString(2)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(3)) map.put(DBSchema.ITEM_TYPE, cursor.getString(3)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getUsers_specialization() { JSONArray data;//from w ww . j av a2 s . c o m data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_USERS_SPECIALIZATION, new String[] { DBSchema.USERS_SPECIALIZATION_USER_ID, DBSchema.USERS_SPECIALIZATION_SPECIALIZATION_ID }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0))// map.put(DBSchema.USERS_SPECIALIZATION_USER_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1))// map.put(DBSchema.USERS_SPECIALIZATION_SPECIALIZATION_ID, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getPath() { JSONArray data;//from ww w.j a v a2 s .c o m data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_PATH, new String[] { DBSchema.PATH_REPORT_ID, DBSchema.PATH_OPTION_ID, DBSchema.PATH_DATA, DBSchema.PATH_SEQUENCE }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0)) map.put(DBSchema.PATH_REPORT_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1)) map.put(DBSchema.PATH_OPTION_ID, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(2)) map.put(DBSchema.PATH_DATA, cursor.getString(2)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(3)) map.put(DBSchema.PATH_SEQUENCE, cursor.getString(3)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getOption() { JSONArray data;/*from ww w. j a va 2 s .c o m*/ data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_OPTION, new String[] { DBSchema.OPTION_ID, DBSchema.OPTION_PARENT_ID, DBSchema.OPTION_NEXT_ID, DBSchema.OPTION_LABEL }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0)) map.put(DBSchema.OPTION_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1)) map.put(DBSchema.OPTION_PARENT_ID, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(2)) map.put(DBSchema.OPTION_NEXT_ID, cursor.getString(2)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(3)) map.put(DBSchema.OPTION_LABEL, cursor.getString(3)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }
From source file:com.narkii.security.info.BaseDataFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { // TODO Auto-generated method stub if (cursor.getCount() == 0) { // Toast.makeText(getActivity(), "load data error", Toast.LENGTH_LONG).show(); return;/*w w w .ja v a 2 s. c o m*/ } if (loader.getId() == Constants.ENTERPRISE_INFO_ID) { if (cursor.getCount() == 1) { cursor.moveToFirst(); enameText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_NAME))); enameText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_NAME))); addressText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_ADDRESS))); addressText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_ADDRESS))); orgaText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_ORGANIZATION_CODE))); orgaText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_ORGANIZATION_CODE))); fileText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_FILE_NUMBER))); fileText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_FILE_NUMBER))); ephoneText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_TELEPHONE))); ephoneText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_TELEPHONE))); efaxText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_FAX))); efaxText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_FAX))); emailText.setText(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_EMAIL))); emailText.setTag(cursor.getString(cursor.getColumnIndex(Enterprise.COLUMN_EMAIL))); specialId = cursor.getInt(cursor.getColumnIndex(Enterprise.COLUMN_SPECIAL)) - 1; Log.d(TAG, "get null special id:" + specialId); preSpecialId = specialId; if (specialId >= 0) specialBox.get(cursor.getInt(cursor.getColumnIndex(Enterprise.COLUMN_SPECIAL)) - 1) .setChecked(true); areaType = cursor.getInt(cursor.getColumnIndex(Enterprise.COLUMN_AREA)); areaSpinner.setSelection((int) (areaType - 1)); enterpriseType = cursor.getInt(cursor.getColumnIndex(Enterprise.COLUMN_FK_ENTERPRISE_TYPE)); typeSpinner.setSelection((int) (enterpriseType - 1)); Log.d(TAG, "init company info area " + cursor.getInt(cursor.getColumnIndex(Enterprise.COLUMN_AREA)) + " type: " + cursor.getInt(cursor.getColumnIndex(Enterprise.COLUMN_FK_ENTERPRISE_TYPE))); } } else if (loader.getId() == Constants.ENTERPRISE_PERSON_ID) { clearPersonInfoView(addResponButton); clearPersonInfoView(addManagerButton); if (personViews.size() > 0) personViews.clear(); if (addPersonViews.size() > 0) addPersonViews.clear(); cursor.moveToFirst(); do { Log.d(TAG, "init person "); int type = cursor.getInt(cursor.getColumnIndex(EnterprisePerson.COLUMN_TYPE)); if (type == 1) {// addPersonInfoView(addResponButton, cursor); } else if (type == 2) {// addPersonInfoView(addManagerButton, cursor); } cursor.moveToNext(); } while (!cursor.isAfterLast()); } else if (loader.getId() == Constants.SPINNER_AREA_ID) { areAdapter.swapCursor(cursor); } else if (loader.getId() == Constants.SPINNER_ENTERPRISE_TYPE_ID) { typeAdapter.swapCursor(cursor); } }
From source file:com.rener.sea.DBHelper.java
public List<Report> getAllReports() { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_REPORT, new String[] { DBSchema.REPORT_ID, DBSchema.REPORT_NAME }, DBSchema.REPORT_STATUS + " !=? ", new String[] { String.valueOf(-1) }, null, null, "date(" + DBSchema.REPORT_DATE_FILED + ") DESC, " + DBSchema.REPORT_NAME + " COLLATE NOCASE", null); ArrayList<Report> reports; reports = new ArrayList<>(); if ((cursor != null) && (cursor.getCount() > 0)) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { reports.add(new Report(cursor.getLong(0), cursor.getString(1), this)); }/*from w w w .j a v a 2s . com*/ db.close(); cursor.close(); } return reports; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getUsers() { JSONArray data;// w w w . j a v a2 s.c om data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_USERS, new String[] { DBSchema.USER_ID, DBSchema.USER_USERNAME, DBSchema.USER_PASSHASH, DBSchema.USER_PERSON_ID, DBSchema.USER_SALT }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0)) map.put(DBSchema.USER_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1)) map.put(DBSchema.USER_USERNAME, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(2)) map.put(DBSchema.USER_PASSHASH, cursor.getString(2)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(3)) map.put(DBSchema.USER_PERSON_ID, cursor.getString(3)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(4)) map.put(DBSchema.USER_SALT, cursor.getString(4)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }
From source file:com.rener.sea.DBHelper.java
private JSONArray getAddress() { JSONArray data;//from ww w . j av a 2s . co m data = new JSONArray(); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_ADDRESS, new String[] { DBSchema.ADDRESS_ID, DBSchema.ADDRESS_LINE1, DBSchema.ADDRESS_CITY, DBSchema.ADDRESS_ZIPCODE, DBSchema.ADDRESS_LINE2 }, DBSchema.MODIFIED + "=?", new String[] { DBSchema.MODIFIED_YES }, null, null, null, null); if (cursor.moveToFirst()) { if ((cursor != null) && (cursor.getCount() > 0)) for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { JSONObject map = new JSONObject(); try { if (!cursor.isNull(0)) map.put(DBSchema.ADDRESS_ID, cursor.getString(0)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(1)) map.put(DBSchema.ADDRESS_LINE1, cursor.getString(1)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(2)) map.put(DBSchema.ADDRESS_CITY, cursor.getString(2)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(3)) map.put(DBSchema.ADDRESS_ZIPCODE, cursor.getString(3)); } catch (JSONException e) { e.printStackTrace(); } try { if (!cursor.isNull(4)) map.put(DBSchema.ADDRESS_LINE2, cursor.getString(4)); } catch (JSONException e) { e.printStackTrace(); } data.put(map); } } db.close(); cursor.close(); return data; }