/** * checking the database Availability based on Availability copying database to the device data * * @return true (if Available) */ private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { Log.e(TAG, "Error is" + e.toString()); } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; }
private boolean checkDataBase() { SQLiteDatabase mCheckDataBase = null; try { String myPath = DB_PATH + DB_NAME; mCheckDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); } catch (SQLiteException mSQLiteException) { Log.e(TAG, "DatabaseNotFound " + mSQLiteException.toString()); } if (mCheckDataBase != null) { mCheckDataBase.close(); } return mCheckDataBase != null; }
private boolean setData(String user, String info) { SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put(FriendService.DB_USERNAME, user); values.put(FriendService.DB_JSON, info); if (info.equals(ServiceMeta.CONNECTION_FAILURE) || info.equals(ServiceMeta.NO_INFO_FOUND)) { return false; } try { db.update(FriendService.DB_TABLE, values, FriendService.DB_USERNAME + "=" + user, null); db.close(); return true; } catch (SQLiteException e) { Log.e(LOG_TAG, e.toString()); db.insert(FriendService.DB_TABLE, null, values); db.close(); return true; } }
/** * Queries reference database for all wifis in specified range around map center. * * @param args Args is an object array containing args[0]: min latitude as double args[1]: max * latitude as double args[2]: min longitude as double args[3]: max longitude as double */ @Override protected final ArrayList<LatLong> doInBackground(final Object... args) { ArrayList<LatLong> points = new ArrayList<LatLong>(); try { WifiCatalogDatabaseHelper databaseHelper = WifiCatalogDatabaseHelper.getInstance(mAppContext); // return empty result list if reference database not available if (databaseHelper.getFilename() == null) { Log.v(TAG, "Wifi catalog database not set - skipping"); return points; } if (!GROUP_WIFIS) { points = databaseHelper.getPoints( (Double) args[MIN_LAT_COL], (Double) args[MAX_LAT_COL], (Double) args[MIN_LON_COL], (Double) args[MAX_LON_COL]); } else { // Option 2 (default): Group in 10m intervals for performance reasons points = databaseHelper.getPointsLazy( (Double) args[MIN_LAT_COL], (Double) args[MAX_LAT_COL], (Double) args[MIN_LON_COL], (Double) args[MAX_LON_COL]); } } catch (final SQLiteException e) { Log.e(TAG, "Sql exception occured: " + e.toString()); } catch (final Exception e) { e.printStackTrace(); } return points; }