List of usage examples for android.database.sqlite SQLiteDatabase rawQuery
public Cursor rawQuery(String sql, String[] selectionArgs)
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<DomainFilter> getAllUserDomainFilters() { List<DomainFilter> domainFilters = new ArrayList<DomainFilter>(); String selectQuery = "SELECT * FROM " + TABLE_DOMAIN_FILTERS + " WHERE " + KEY_SOURCE + " IS NULL "; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); // looping through all rows and adding to list if (c.moveToFirst()) { do {/*from w w w . j a v a 2 s . c o m*/ DomainFilter domainFilter = new DomainFilter(); domainFilter.setId(c.getInt(c.getColumnIndex(KEY_ID))); domainFilter.setContent((c.getString(c.getColumnIndex(KEY_CONTENT)))); domainFilter.setSource((c.getString(c.getColumnIndex(KEY_SOURCE)))); domainFilter.setModified(c.getString(c.getColumnIndex(KEY_MODIFIED))); domainFilter.setWildcard((c.getInt(c.getColumnIndex(KEY_WILDCARD)))); domainFilters.add(domainFilter); } while (c.moveToNext()); } return domainFilters; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<String> getAllDomainFiltersForSource(String source) { List<String> filters = new ArrayList<>(); String selectQuery = "SELECT " + KEY_CONTENT + " FROM " + TABLE_DOMAIN_FILTERS + " WHERE " + KEY_SOURCE + " = ?"; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, new String[] { source }); int count = 0; // looping through all rows and adding to list if (c.moveToFirst()) { do {// www . j av a2s . c o m filters.add(c.getString(c.getColumnIndex(KEY_CONTENT))); count++; } while (c.moveToNext() && count < LIMIT); } if (count == LIMIT) { filters.add("--- Omitted " + (c.getCount() - LIMIT) + " entries ---"); } return filters; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<AllowedDomain> getAllAllowedDomains() { List<AllowedDomain> allowedDomains = new ArrayList<>(); try {/* w w w .j av a 2 s . c om*/ String selectQuery = "SELECT * FROM " + TABLE_ALLOWED_DOMAINS; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); if (c.moveToFirst()) { do { AllowedDomain allowedDomain = new AllowedDomain(c.getString(c.getColumnIndex(KEY_APP_INFO)), c.getString(c.getColumnIndex(KEY_PERMISSIONS))); allowedDomains.add(allowedDomain); } while (c.moveToNext()); } } catch (Exception e) { Log.d("ERROR", e.getMessage()); } return allowedDomains; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<BlockedDomain> getAllBlockedDomains() { List<BlockedDomain> blockedDomains = new ArrayList<>(); try {//w w w. j ava 2 s. c om String selectQuery = "SELECT * FROM " + TABLE_BLOCKED_DOMAINS; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); if (c.moveToFirst()) { do { BlockedDomain blockedDomain = new BlockedDomain(c.getString(c.getColumnIndex(KEY_APP_INFO)), c.getString(c.getColumnIndex(KEY_PERMISSIONS))); blockedDomains.add(blockedDomain); } while (c.moveToNext()); } } catch (Exception e) { Log.d("ERROR", e.getMessage()); } return blockedDomains; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<TrustedAccessPoint> getAllTrustedAccessPoints() { List<TrustedAccessPoint> trustedAccessPoints = new ArrayList<>(); try {// www.java 2s.c o m String selectQuery = "SELECT * FROM " + TABLE_TRUSTED_ACCESS_POINTS; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); if (c.moveToFirst()) { do { TrustedAccessPoint trustedAccessPoint = new TrustedAccessPoint( c.getString(c.getColumnIndex(KEY_SSID)), c.getString(c.getColumnIndex(KEY_BSSID))); trustedAccessPoints.add(trustedAccessPoint); } while (c.moveToNext()); } } catch (Exception e) { Log.d("ERROR", e.getMessage()); } return trustedAccessPoints; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<PendingNotification> getAllPendingNotifications() { List<PendingNotification> pendingNotifications = new ArrayList<>(); try {//from w ww . j a v a 2s .com String selectQuery = "SELECT * FROM " + TABLE_PENDING_NOTIFICATIONS; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); if (c.moveToFirst()) { do { PendingNotification pendingNotification = new PendingNotification( c.getString(c.getColumnIndex(KEY_APP_INFO)), c.getString(c.getColumnIndex(KEY_PERMISSIONS)), c.getInt(c.getColumnIndex(KEY_NOTIFICATION_ID))); pendingNotifications.add(pendingNotification); } while (c.moveToNext()); } } catch (Exception e) { Log.d("ERROR", e.getMessage()); } return pendingNotifications; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<String[]> getAllPermissionsPerAllowedDomain() { List<String[]> result = new ArrayList<>(); try {/*from w w w . java 2 s. c o m*/ String KEY_CONCAT_PERMISSIONS = "concat_permissions"; String selectQuery = "SELECT " + KEY_APP_INFO + ", GROUP_CONCAT(" + KEY_PERMISSIONS + ") AS " + KEY_CONCAT_PERMISSIONS + " FROM (" + "SELECT " + KEY_APP_INFO + ", " + KEY_PERMISSIONS + " FROM " + TABLE_ALLOWED_DOMAINS + " ORDER BY " + KEY_APP_INFO + ", " + KEY_PERMISSIONS + ") " + "GROUP BY " + KEY_APP_INFO; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); if (c.moveToFirst()) { do { result.add(new String[] { c.getString(c.getColumnIndex(KEY_APP_INFO)), c.getString(c.getColumnIndex(KEY_CONCAT_PERMISSIONS)) }); } while (c.moveToNext()); } } catch (Exception e) { Log.d("ERROR", e.getMessage()); } return result; }
From source file:eu.operando.operandoapp.database.DatabaseHelper.java
public List<String[]> getAllPermissionsPerBlockedDomain() { List<String[]> result = new ArrayList<>(); try {// w w w .j av a 2 s . c o m String KEY_CONCAT_PERMISSIONS = "concat_permissions"; String selectQuery = "SELECT " + KEY_APP_INFO + ", GROUP_CONCAT(" + KEY_PERMISSIONS + ") AS " + KEY_CONCAT_PERMISSIONS + " FROM (" + "SELECT " + KEY_APP_INFO + ", " + KEY_PERMISSIONS + " FROM " + TABLE_BLOCKED_DOMAINS + " ORDER BY " + KEY_APP_INFO + ", " + KEY_PERMISSIONS + ") " + "GROUP BY " + KEY_APP_INFO; SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); if (c.moveToFirst()) { do { result.add(new String[] { c.getString(c.getColumnIndex(KEY_APP_INFO)), c.getString(c.getColumnIndex(KEY_CONCAT_PERMISSIONS)) }); } while (c.moveToNext()); } } catch (Exception e) { Log.d("ERROR", e.getMessage()); } return result; }
From source file:net.smart_json_database.JSONDatabase.java
private Cursor fetchCursorByRawSQL(SQLiteDatabase db, String sql, String[] params, Order order) { // TODO send factor //Cursor c = db.rawQueryWithFactory(factory, sql, params, null, null); Cursor c = db.rawQuery(sql, params); return c;//from w ww . j a v a 2 s . com }
From source file:com.fitforbusiness.nafc.dashboard.DashBoardFragment.java
private void loadSessions() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); String startDate;/*from w w w . j a va2s.c om*/ startDate = sdf.format(Calendar.getInstance().getTime()); ArrayList<HashMap<String, Object>> mapSessionArray = new ArrayList<HashMap<String, Object>>(); SQLiteDatabase sqlDB = null; try { sqlDB = DatabaseHelper.instance().getReadableDatabase(); String query = "select * " + " from " + Table.Sessions.TABLE_NAME + " where " + Table.DELETED + " = 0 and " + Table.Sessions.START_DATE + " = \'" + startDate + "\'"; Log.d("query is ", query); assert sqlDB != null; Cursor cursor = sqlDB.rawQuery(query, null); LinkedHashMap<String, Object> row; while (cursor.moveToNext()) { row = new LinkedHashMap<String, Object>(); row.put("_id", cursor.getString(cursor.getColumnIndex(Table.Sessions.ID))); row.put("name", Utils.timeFormatAMPM(cursor.getString(cursor.getColumnIndex(Table.Sessions.START_TIME)))); rowData = getImageName(cursor.getString(cursor.getColumnIndex(Table.Sessions.GROUP_ID)), cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_TYPE))); row.put("photo", rowData.getImageName()); row.put("secondLabel", rowData.getPersonName()); row.put("thirdLabel", status[cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_STATUS))]); mapSessionArray.add(row); } cursor.close(); } catch (Exception e) { e.printStackTrace(); } finally { } CustomAsyncTaskListAdapter adapter = new CustomAsyncTaskListAdapter(getActivity(), R.layout.calendar_day_view_session_row, R.id.ivRowImage, R.id.tvFirstName, R.id.tvSecondLabel, R.id.tvThirdLabel, mapSessionArray); sessionList.setAdapter(adapter); }