List of usage examples for android.database.sqlite SQLiteDatabase delete
public int delete(String table, String whereClause, String[] whereArgs)
From source file:com.dm.material.dashboard.candybar.databases.Database.java
public void deleteAllWalls() { SQLiteDatabase db = this.getWritableDatabase(); db.delete("SQLITE_SEQUENCE", "NAME = ?", new String[] { TABLE_WALLPAPERS }); db.delete(TABLE_WALLPAPERS, null, null); db.close();//from ww w. ja v a 2s.c om }
From source file:org.jsharkey.oilcan.ScriptDatabase.java
/** * Delete a specific script.// w ww . ja va2s . c om */ public void deleteScript(long id) { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_SCRIPTS, "_id = ?", new String[] { Long.toString(id) }); }
From source file:pl.selvin.android.syncframework.content.TableInfo.java
final public void DeleteWithUri(String uri, SQLiteDatabase db) { db.delete(name, _.uriP, new String[] { uri }); }
From source file:com.cuddlesoft.nori.database.APISettingsDatabase.java
/** * Delete a row from the database.//w w w . j a v a 2s . co m * * @param id Row ID. * @return Number of rows affected. */ public int delete(long id) { // Remove row from the database. SQLiteDatabase db = getWritableDatabase(); final int rows = db.delete(TABLE_NAME, COLUMN_ID + " = ?", new String[] { Long.toString(id) }); db.close(); sendUpdateNotification(); return rows; }
From source file:eu.rubenrosado.tinypasswordmanager.AllRows.java
public void onClickDelete(View v) { DBHelper dbhelper = new DBHelper(this); SQLiteDatabase sql = dbhelper.getWritableDatabase(); int position = lv.getPositionForView(v); sql.delete(DBHelper.TABLENAME, DBHelper.COLID + "=" + String.valueOf(spArray.get(position).getId()), null); sql.close();// ww w . java 2 s. co m dbhelper.close(); spArray.remove(position); decryptedPasswords.remove(position); adapter.notifyDataSetChanged(); }
From source file:com.example.google.touroflondon.data.TourDbHelper.java
/** * Extract Route data from a {@link JSONArray} of save it in the database. * //from w ww .j a v a 2s. c om * @param data */ public void loadRoute(JSONArray data) throws JSONException { SQLiteDatabase db = this.getWritableDatabase(); // Empty the route table to remove all existing data db.delete(TourContract.RouteEntry.TABLE_NAME, null, null); // Need to complete transaction first to clear data db.close(); // Begin the insert transaction db = this.getWritableDatabase(); db.beginTransaction(); // Loop over each location in array for (int i = 0; i < data.length(); i++) { // extract data JSONObject poi = data.getJSONObject(i); final double lat = poi.getDouble("lat"); final double lng = poi.getDouble("lng"); // Construct insert statement ContentValues cv = new ContentValues(); cv.put(TourContract.RouteEntry.COLUMN_NAME_LAT, lat); cv.put(TourContract.RouteEntry.COLUMN_NAME_LNG, lng); // Insert data db.insert(TourContract.RouteEntry.TABLE_NAME, null, cv); } if (db != null) { // All insert statement have been submitted, mark transaction as // successful db.setTransactionSuccessful(); db.endTransaction(); } }
From source file:com.example.android.touroflondon.data.TourDbHelper.java
/** * Extract Route data from a {@link JSONArray} of save it in the database. * * @param data//from www .j a v a 2 s . co m */ public void loadRoute(JSONArray data) throws JSONException { SQLiteDatabase db = this.getWritableDatabase(); // Empty the route table to remove all existing data db.delete(TourContract.RouteEntry.TABLE_NAME, null, null); // Need to complete transaction first to clear data db.close(); // Begin the insert transaction db = this.getWritableDatabase(); db.beginTransaction(); // Loop over each location in array for (int i = 0; i < data.length(); i++) { // extract data JSONObject poi = data.getJSONObject(i); final double lat = poi.getDouble("lat"); final double lng = poi.getDouble("lng"); // Construct insert statement ContentValues cv = new ContentValues(); cv.put(TourContract.RouteEntry.COLUMN_NAME_LAT, lat); cv.put(TourContract.RouteEntry.COLUMN_NAME_LNG, lng); // Insert data db.insert(TourContract.RouteEntry.TABLE_NAME, null, cv); } if (db != null) { // All insert statement have been submitted, mark transaction as successful db.setTransactionSuccessful(); db.endTransaction(); } }
From source file:com.manning.androidhacks.hack043.provider.BatchNumbersContentProvider.java
@Override public int delete(Uri uri, String selection, String[] selectionArgs) { SQLiteDatabase db = dbHelper.getWritableDatabase(); int count;//w w w . j a v a2 s . c om switch (sUriMatcher.match(uri)) { case ITEM: count = db.delete(TABLE_NAME, selection, selectionArgs); break; case ITEM_ID: String id = uri.getPathSegments().get(1); count = db.delete(TABLE_NAME, COLUMN_ID + "=" + id + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ")" : ""), selectionArgs); break; default: throw new RuntimeException("Unkown URI: " + uri); } getContext().getContentResolver().notifyChange(uri, null); return count; }
From source file:com.manning.androidhacks.hack023.provider.TodoContentProvider.java
@Override public int delete(Uri uri, String selection, String[] selectionArgs) { SQLiteDatabase db = dbHelper.getWritableDatabase(); int count;// w w w . ja v a2 s .co m switch (sUriMatcher.match(uri)) { case TODO: count = db.delete(TODO_TABLE_NAME, selection, selectionArgs); break; case TODO_ID: String id = uri.getPathSegments().get(1); count = db.delete(TODO_TABLE_NAME, COLUMN_ID + "=" + id + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ")" : ""), selectionArgs); break; default: throw new RuntimeException("Unkown URI: " + uri); } getContext().getContentResolver().notifyChange(uri, null); return count; }
From source file:com.example.shutapp.DatabaseHandler.java
/** * Delete a chat room./*from w w w . j a va 2 s . co m*/ * @param chatroom */ public void deleteChatroom(Chatroom chatroom) { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_CHATROOMS, KEY_NAME + " = ?", new String[] { chatroom.getName() }); db.close(); }