delete database table row By Id - Android Database

Android examples for Database:Table Row Delete

Description

delete database table row By Id

Demo Code


//package com.book2s;
import android.content.Context;

import android.database.sqlite.SQLiteDatabase;

public class Main {
    public static void deleteById(Context context, String tableName, int id) {
        SQLiteDatabase db = getDatabase(context);
        db.delete(tableName, "id=" + id, null);
        db.close();//from www  .  j  ava2  s  . c o m
    }

    public static SQLiteDatabase getDatabase(Context context) {
        return context.openOrCreateDatabase("tomato.db",
                Context.MODE_PRIVATE, null);
    }
}

Related Tutorials