Android的删除SQLite数据库的数据 [英] Android delete data from SQLite database

查看:489
本文介绍了Android的删除SQLite数据库的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序创建一个SQLite的Andr​​oid分贝。我可以添加信息到数据库没有任何问题。但我不能够从它删除任何东西。

I've created a SQLite Android dB in my app. I can add info to the dB without any problem. But I'm not able to delete anything from it.

这是我的code:

        final SQLManager hon = new SQLManager(this);
        b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        // TODO Auto-generated method stub

           long l = 3;
           hon.open();
           hon.deleteEntry(l);
           hon.close();
        }
                });

这是方法deleteEntry()

And here is the method "deleteEntry()":

       public void deleteEntry(long l) {
   // TODO Auto-generated method stub
   ourDatabase.delete(DATABASE_TABLE, null, null);
       }

这本该是删除整个分贝,不是吗?这使得删除功能时pressed是比分贝相同观点的按钮,这是一个问题?

It was supposed to delete the whole dB, wasn't it? The button which makes the delete function when pressed is in the same view than the dB, is this a problem?

推荐答案

您可以使用下面的code

you can use the following code

ourDatabase.execSQL("delete from <TableName>");

这篇关于Android的删除SQLite数据库的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆