如何在Android中的按钮单击事件中从数据库中删除TextBox中的选定数据?

时间:2021-12-24 10:38:57

I have an EditText and a Button in my Android application. When I entered the values in the EditText, the values were stored in a database. Now I want to delete these values from the batabase on the Button's click event. How can I do this?

我的Android应用程序中有一个EditText和一个Button。当我在EditText中输入值时,值存储在数据库中。现在我想从Button的click事件中的batabase中删除这些值。我怎样才能做到这一点?

How can I delete the record?

如何删除记录?

Thanks in advance..

提前致谢..

Here is my code what I am doing:-

这是我的代码我在做什么: -

btn2.setOnClickListener((new View.OnClickListener(){
      public void onClick(View v){  

            String value = ((TextView) output).getText().toString();
            if(dh.equals(value))
            {
                   dh.delete(value);
                   dh.selectAll();
            }


      }

}));

}

1 个解决方案

#1


0  

You should create database connectivity and then you should write proper query inside onClick(View v) which will delete the record from database.

您应该创建数据库连接,然后您应该在onClick(View v)中编写正确的查询,这将从数据库中删除记录。

#1


0  

You should create database connectivity and then you should write proper query inside onClick(View v) which will delete the record from database.

您应该创建数据库连接,然后您应该在onClick(View v)中编写正确的查询,这将从数据库中删除记录。