本文整理汇总了Java中android.database.sqlite.SQLiteDatabase.delete方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDatabase.delete方法的具体用法?Java SQLiteDatabase.delete怎么用?Java SQLiteDatabase.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.sqlite.SQLiteDatabase
的用法示例。
在下文中一共展示了SQLiteDatabase.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: b
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public synchronized void b(String str) {
if (!TextUtils.isEmpty(str)) {
SQLiteDatabase writableDatabase = getWritableDatabase();
if (writableDatabase != null) {
try {
writableDatabase.delete("via_cgi_report", "type = ?", new String[]{str});
if (writableDatabase != null) {
writableDatabase.close();
}
} catch (Exception e) {
com.tencent.open.a.f.e(a, "clearReportItem has exception.");
if (writableDatabase != null) {
writableDatabase.close();
}
} catch (Throwable th) {
if (writableDatabase != null) {
writableDatabase.close();
}
}
}
}
}
示例2: delete
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public boolean delete(long messageId) {
long threadId = getThreadIdForMessage(messageId);
MmsAddressDatabase addrDatabase = DatabaseFactory.getMmsAddressDatabase(context);
AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
attachmentDatabase.deleteAttachmentsForMessage(messageId);
addrDatabase.deleteAddressesForId(messageId);
SQLiteDatabase database = databaseHelper.getWritableDatabase();
database.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});
boolean threadDeleted = DatabaseFactory.getThreadDatabase(context).update(threadId, false);
notifyConversationListeners(threadId);
return threadDeleted;
}
示例3: deleteIssues
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void deleteIssues(final IssuesModel issuesModel) {
long issuesId = issuesModel.getId();
SQLiteDatabase db = getDatabase();
try {
db.beginTransaction();
db.delete(DataBaseHelper.TABLE_ISSUES, COLUMN_ISSUE_ID + " = " + issuesId, null);
db.setTransactionSuccessful();
} catch (Exception e) {
Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
} finally {
db.endTransaction();
}
}
示例4: deleteEmptyFolders
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
* Deletes any empty folder from the DB.
* @return Ids of deleted folders.
*/
private ArrayList<Long> deleteEmptyFolders() {
ArrayList<Long> folderIds = new ArrayList<>();
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
try {
// Select folders whose id do not match any container value.
String selection = LauncherSettings.Favorites.ITEM_TYPE + " = "
+ LauncherSettings.Favorites.ITEM_TYPE_FOLDER + " AND "
+ LauncherSettings.Favorites._ID + " NOT IN (SELECT " +
LauncherSettings.Favorites.CONTAINER + " FROM "
+ Favorites.TABLE_NAME + ")";
Cursor c = db.query(Favorites.TABLE_NAME,
new String[] {LauncherSettings.Favorites._ID},
selection, null, null, null, null);
while (c.moveToNext()) {
folderIds.add(c.getLong(0));
}
c.close();
if (!folderIds.isEmpty()) {
db.delete(Favorites.TABLE_NAME, Utilities.createDbSelectionQuery(
LauncherSettings.Favorites._ID, folderIds), null);
}
db.setTransactionSuccessful();
} catch (SQLException ex) {
Log.e(TAG, ex.getMessage(), ex);
folderIds.clear();
} finally {
db.endTransaction();
}
return folderIds;
}
示例5: deleteItemsWithMeasurementId
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void deleteItemsWithMeasurementId(final long measurementId) {
SQLiteDatabase db = getDatabase();
try {
db.beginTransaction();
db.delete(DataBaseHelper.TABLE_GEO_TAGS, COLUMN_GEO_TAG_MEASUREMENT_ID + " = " + measurementId, null);
db.setTransactionSuccessful();
} catch (Exception e) {
Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
} finally {
db.endTransaction();
}
}
示例6: delete
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public int delete(final TagModel data) {
long id = data.getId();
int count = 0;
SQLiteDatabase db = getDatabase();
try {
db.beginTransaction();
count = db.delete(DataBaseHelper.TABLE_TAGS, COLUMN_TAG_ID + " = " + id, null);
db.setTransactionSuccessful();
} catch (Exception e) {
Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
} finally {
db.endTransaction();
}
return count;
}
示例7: deleteHelpMeMsgById
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void deleteHelpMeMsgById(int id) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_NAME, "id=?",
new String[] { Integer.toString(id) });
db.close();
}
示例8: deleteAll
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public boolean deleteAll(SQLiteDatabase sqLiteDatabase, String tableName)
{
//Log.d(DEG_TAG, "deleteAll");
int number = sqLiteDatabase.delete(tableName, null, null);
//Log.d(DEG_TAG, "deleteAll_result:" + number);
if (number != 0)
{
return true;
}
else
{
return false;
}
}
示例9: clearDrafts
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void clearDrafts(Set<Long> threadIds) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
StringBuilder where = new StringBuilder();
List<String> arguments = new LinkedList<>();
for (long threadId : threadIds) {
where.append(" OR ")
.append(THREAD_ID)
.append(" = ?");
arguments.add(String.valueOf(threadId));
}
db.delete(TABLE_NAME, where.toString().substring(4), arguments.toArray(new String[0]));
}
示例10: delete
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**删除数据
* @param column
* @param value
* @return
*/
public int delete(String column, String value) {
SQLiteDatabase db = this.getWritableDatabase();
try {
return db.delete(TABLE_NAME, getSelection(column), getSelectionArgs(column, value));
} catch (Exception e) {
Log.e(TAG, "update try { return db.delete(.... } catch (Exception e) {\n " + e.getMessage());
}
return 0;
}
示例11: deleteAllRecordsFromDB
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void deleteAllRecordsFromDB() {
Context appContext = InstrumentationRegistry.getTargetContext();
FavoritesDbHelper dbHelper = new FavoritesDbHelper(appContext);
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(FavoritesContract.FavoriteColumns.FAVORITE_MOVIES_TBL, null, null);
db.delete(FavoritesContract.FavoriteColumns.FAVORITE_TV_SHOWS_TBL, null, null);
db.delete(FavoritesContract.FavoriteColumns.FAVORITE_PERSON_TBL, null, null);
db.close();
}
示例12: deleteNote
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public Integer deleteNote(Integer id) {
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(NOTES_TABLE_NAME,
""+NOTES_COLUMN_ID+" = ? ",
new String[] { Integer.toString(id) });
}
示例13: delete
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public synchronized int delete(Uri uri, String selection,
String[] selectionArgs) {
// Opens the database object in "write" mode.
SQLiteDatabase db = mHistoryHelper.getWritableDatabase();
String finalWhere;
int count;
// Does the delete based on the incoming URI pattern.
switch (URI_MATCHER.match(uri)) {
/*
* If the incoming pattern matches the general pattern for history
* items, does a delete based on the incoming "where" columns and
* arguments.
*/
case URI_HISTORY:
count = db.delete(HistoryContract.TABLE_NAME, selection,
selectionArgs);
break;// URI_HISTORY
/*
* If the incoming URI matches a single note ID, does the delete based
* on the incoming data, but modifies the where clause to restrict it to
* the particular history item ID.
*/
case URI_HISTORY_ID:
/*
* Starts a final WHERE clause by restricting it to the desired
* history item ID.
*/
finalWhere = DbUtils.SQLITE_FTS_COLUMN_ROW_ID + " = "
+ uri.getLastPathSegment();
/*
* If there were additional selection criteria, append them to the
* final WHERE clause
*/
if (selection != null)
finalWhere = finalWhere + " AND " + selection;
// Performs the delete.
count = db.delete(HistoryContract.TABLE_NAME, finalWhere,
selectionArgs);
break;// URI_HISTORY_ID
// If the incoming pattern is invalid, throws an exception.
default:
throw new IllegalArgumentException("UNKNOWN URI " + uri);
}
/*
* Gets a handle to the content resolver object for the current context,
* and notifies it that the incoming URI changed. The object passes this
* along to the resolver framework, and observers that have registered
* themselves for the provider are notified.
*/
getContext().getContentResolver().notifyChange(uri, null);
// Returns the number of rows deleted.
return count;
}
示例14: delete
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void delete(int id){
SQLiteDatabase db = getWritableDatabase();
db.delete(TABLE_NAME, "_id=?", new String[]{String.valueOf(id)});
}
示例15: delete
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void delete(long user_Id)
{
SQLiteDatabase db = dbHandler.getWritableDatabase();
db.delete(User.TABLE, User.KEY_ID + "= ?", new String[] { String.valueOf(user_Id) });
db.close(); // Closing database connection
}