选择查询,以检查现有记录在Android上的SQLite数据库 [英] Select query to check the existing record in the SQLite Database in android

查看:290
本文介绍了选择查询,以检查现有记录在Android上的SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的查询,以检查在数据库中的特定记录是否已经存在或不适合我的应用程序。

I want to know the Query to check whether the particular Record in the DataBase already exists or not for my application.

我已经建立了一个功能,这些,但它不能正常工作。

I have made one function for these, but it is not working properly.

public boolean ifExisting(String name) {
    Cursor c = db.rawQuery("SELECT * FROM " + TABLE_NAME + "WHERE" + "name" + "=" + name, null);
    if(c.getCount() == 0)
     return false; 
else
     return true;
}

这是我需要的地方进行检查复制过程的作用的地方。

This is the place where I need to perform the function of checking for the Duplication Process.

if(dh.ifExisting(dataVector.get(position)) == true) {

} else {
dh.insert(dataVector.get(position));
} 

任何人都可以请帮助我。

Can anybody please help me.

谢谢, 大卫

推荐答案

你能成为一个更具体一点? 没有正常工作是不是一个真正的问题说明。

Can you be a bit more specific? "no working properly" isn't a real problem description.

总之,您的查询缺少一些空间:

Anyway, your query is missing some spaces:

"SELECT * FROM " + TABLE_NAME + "WHERE" + "name" + "=" + name
// if you would print the string you would get this:
"SELECT * FROM TABLE_NAMEWHEREname=name"

这篇关于选择查询,以检查现有记录在Android上的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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