当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteDatabase.delete方法代码示例

本文整理汇总了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();
                }
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:f.java

示例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;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:14,代码来源:MmsDatabase.java

示例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();
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:14,代码来源:IssuesDAO.java

示例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;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:36,代码来源:LauncherProvider.java

示例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();
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:13,代码来源:GeoTagDAO.java

示例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;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:16,代码来源:TagDAO.java

示例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();

}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:8,代码来源:HelpMeMsgDB.java

示例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;
	}
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:16,代码来源:SQLManager.java

示例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]));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:DraftDatabase.java

示例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;
}
 
开发者ID:TommyLemon,项目名称:APIJSON-Android-RxJava,代码行数:15,代码来源:SQLHelper.java

示例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();
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:11,代码来源:TestProvider.java

示例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) });
}
 
开发者ID:zanedb,项目名称:open-journal-android,代码行数:7,代码来源:DBHelper.java

示例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;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:63,代码来源:HistoryProvider.java

示例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)});
}
 
开发者ID:MarukoZ,项目名称:FaceRecognition,代码行数:5,代码来源:DBHelper.java

示例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
}
 
开发者ID:ecaroff,项目名称:sekai,代码行数:7,代码来源:UserRepo.java


注:本文中的android.database.sqlite.SQLiteDatabase.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。