List of usage examples for android.database.sqlite SQLiteDatabase close
public void close()
From source file:org.egov.android.data.SQLiteHelper.java
/** * Update data in table//from w w w .j a va2s . com * * @param tableName * @param ContentValues * @param whereClause * @param whereArgs */ public int update(String tableName, ContentValues cv, String whereClause, String[] whereArgs) { SQLiteDatabase db = getWritableDatabase(); int result = db.update(tableName, cv, whereClause, whereArgs); db.close(); return result; }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static void groupMarkAllRead(String group, Context context) { int groupid = getGroupIdFromName(group, context); if (groupid == -1) return;/*from w w w . j a va 2 s.com*/ DBHelper db = new DBHelper(context); SQLiteDatabase dbWrite = db.getWritableDatabase(); String query = "UPDATE headers SET read=1, read_unixdate=" + System.currentTimeMillis() + " WHERE subscribed_group_id=" + groupid; dbWrite.execSQL(query); query = "UPDATE subscribed_groups SET unread_count=0 WHERE _ID=" + groupid; dbWrite.execSQL(query); dbWrite.close(); db.close(); }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static String getGroupNameFromId(int groupid, Context context) { DBHelper db = new DBHelper(context); SQLiteDatabase dbread = db.getReadableDatabase(); String query = "SELECT name FROM subscribed_groups WHERE _id=" + groupid; Cursor cur = dbread.rawQuery(query, null); if (cur.getCount() != 1) { Log.w("GroundhogReader", "Trying to get name for groupid " + groupid + " which doesnt exists on DB"); cur.close();// w w w. j ava 2 s. c o m dbread.close(); db.close(); return null; } cur.moveToFirst(); String groupname = cur.getString(0); cur.close(); dbread.close(); db.close(); return groupname; }
From source file:com.clutch.ClutchStats.java
public void deleteABLogs(double ts) { SQLiteDatabase db = this.getWritableDatabase(); Object[] args = { ts };/*from w ww. j a v a 2s . c o m*/ db.execSQL("DELETE FROM ablog WHERE ts <= ?", args); db.close(); }
From source file:com.example.shutapp.DatabaseHandler.java
/** * Copies your database from your local downloaded database that is copied from the server * into the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */// www .j a va 2 s .com private void copyServerDatabase() { // by calling this line an empty database will be created // into the default system path of this app - we will then // overwrite this with the database from the server SQLiteDatabase db = getReadableDatabase(); db.close(); OutputStream os = null; InputStream is = null; try { Log.d(TAG, "Copying DB from server version into app"); is = mContext.openFileInput("db_name.s3db"); os = new FileOutputStream("/data/data/com.example.shutapp/databases" + "/chatroomsManager"); copyFile(os, is); } catch (Exception e) { String exception = e.toString(); Log.e(TAG, "Server Database was not found - did it download correctly?" + exception); } finally { try { //Close the streams if (os != null) { os.close(); } if (is != null) { is.close(); } } catch (IOException e) { String exception = e.toString(); Log.e(TAG, "failed to close databases" + exception); } } }
From source file:org.zoumbox.mh_dla_notifier.sp.PublicScriptsProxy.java
public static List<MhSpRequest> listLatestRequests(Context context, String trollId, int count) { List<MhSpRequest> result = new ArrayList<MhSpRequest>(); String query = String.format(SQL_LIST_REQUESTS, count); MhDlaSQLHelper helper = new MhDlaSQLHelper(context); SQLiteDatabase database = helper.getReadableDatabase(); Calendar calendar = Calendar.getInstance(); Cursor cursor = database.rawQuery(query, new String[] { trollId }); while (cursor.moveToNext()) { long startTimeMillis = cursor.getLong(0); long endTimeMillis = cursor.getLong(1); String scriptName = cursor.getString(2); String status = cursor.getString(3); calendar.setTimeInMillis(startTimeMillis); Date date = calendar.getTime(); PublicScript script = PublicScript.valueOf(scriptName); long duration = 0; if (endTimeMillis > 0) { duration = endTimeMillis - startTimeMillis; }//w w w. j av a 2 s. c om MhSpRequest request = new MhSpRequest(date, duration, script, status); result.add(request); } cursor.close(); database.close(); return result; }
From source file:com.clutch.ClutchStats.java
public void deleteLogs(double beforeOrEqualTo) { SQLiteDatabase db = this.getWritableDatabase(); Object[] args = { beforeOrEqualTo }; db.execSQL("DELETE FROM stats WHERE ts <= ?", args); db.close(); }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static int getGroupIdFromName(String group, Context context) { DBHelper db = new DBHelper(context); SQLiteDatabase dbread = db.getReadableDatabase(); // First get the group ID String query = "SELECT _ID FROM subscribed_groups WHERE name=" + esc(group); Cursor cur = dbread.rawQuery(query, null); if (cur.getCount() != 1) { // WTF?? Log.w("GroundhogReader", "Trying to get id for group named " + group + " which doesnt exists on DB"); cur.close();/*ww w . j a v a 2 s . co m*/ dbread.close(); db.close(); return -1; } cur.moveToFirst(); int groupid = cur.getInt(0); cur.close(); dbread.close(); db.close(); return groupid; }
From source file:github.popeen.dsub.util.SongDBHandler.java
public synchronized void addSong(int instance, DownloadFile downloadFile) { SQLiteDatabase db = this.getWritableDatabase(); addSong(db, instance, downloadFile); db.close(); }
From source file:edu.nyu.cs.omnidroid.app.controller.external.actions.GMailService.java
/** * Get the username and password for the Gmail account */// w ww .ja va2 s .c o m private void extractUserCredentials() { DbHelper omniDbHelper = new DbHelper(this); SQLiteDatabase database = omniDbHelper.getWritableDatabase(); RegisteredAppDbAdapter registeredAppDbAdapter = new RegisteredAppDbAdapter(database); account = registeredAppDbAdapter.getAccountCredentials(DbHelper.AppName.GMAIL, ""); database.close(); omniDbHelper.close(); }