English 中文(简体)
如何将案文外地价值与文本领域输入的数据库价值进行比较
原标题:how to compare the text field values with database values which is entered in the text field

实际上,我不想接受数据库中储存的文本领域(即独特的价值)已经输入的同一名称。

例如,我在文本领域打上了“健康”的名称,并节省了这一名称。 如果再次进入同一名字,它就赢得了接受。

我在下文尝试过,但没有工作。 请帮助我。

boolean ifExisting(String cat)
     {
      Cursor c = db.rawQuery("SELECT * FROM " + "restaurants" + "WHERE" + "category" + "=" + cat, null); 
         if(c.getCount() == 0)
         {
          return; 
         } 
          else
          {
           return;
          }
     }
       insert();
问题回答

您的“WHERE”字上没有任何空间。 页: 1

"SELECT * FROM restaurantsWHEREcategory=" + cat

仅增加空间,应当更好。

顺便说一句,使用 raw子非常缓慢,因为时间被用来平息你的扼杀。 你们应当看一看二氧化二氮样本/目录中的灯光灯。

Three issues in your code:

  • 您的职衔为“蓝色回归”类型,但是在您的“条码”两种情况下,您的职衔是<>无<>>。 也许你应努力恢复一种适当的ool价值?

  • 你们应当检查所有微薄的错误操作。 否则的话,他们就会对你无声不报,你的法典将仅仅假定,在行文中没有对应的行文——如果它没有错误的话。

  • 通过加固地铺设查询应当是非法的。 这是一种非常不安全的做法,它打开了你的卡勒克语,用于注射攻击。 如果您的用户进入“italian”;删除cat中文本领域的内容? 你们应当利用东道参数来防范这种情况。

EDIT:

As per LadaRaider s answer, you also seem to be missing a few spaces in your SQL query. Yet another reason not to concatenate strings to build it.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...