Android Sqlite IN, NOT IN syntax --- not int (?)

处理where column_name not in (?):如果后面是一串字符或数字组合时,不可以直接用(?)来处理,而应该将这些字符组合直接作为条件字符串的一部分。

1. where column_name not in (‘name1‘,‘name2‘)

2. db.query(TABLE, new String[] { "id", ""}, String.format(" type NOT IN (%s)", argsArrayToString(arrays)), null, null, null, null);

You cannot place just one ‘?‘ instead of a list of values. As such, there is little to gain from trying to parametrize lists. One can, of course, create 2,4,16-value prepared statements ..." type NOT IN (?,?)", new String[]{ "connect","answer" },... but even on a server with remote RDBMS it has questionable value. Istead, do

db.query(TABLE, new String[] { "id", ""}, " type NOT IN (‘connect‘,‘answer‘)",
     null, null, null, null);

if the list is dynamic, you will have to escape the strings and put them into single quoted list.

Via: http://stackoverflow.com/questions/4707367/android-sqlite-in-not-in-syntax

时间: 2024-08-11 05:45:18

Android Sqlite IN, NOT IN syntax --- not int (?)的相关文章

【原创】android——SQLite实现简单的注册登陆(已经美化)

1,Main_activity的xmL配置 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_pa

Android Sqlite的操作

1.写一个类继承SQLiteOpenHelper public class MyHelper extends SQLiteOpenHelper { public MyHelper(Context context) { super(context, Const.DB_DBNAME , null, Const.DB_VERSION); // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteData

Android SQLite的使用,基本的增删改查效果,以及ListView的效果显示

1 package com.example.sqlitetest; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 import android.content.ContentValues; 6 import android.content.Context; 7 import android.database.Cursor; 8 import android.database.sqlite.SQLiteDatabase; 9

Android+Sqlite 实现古诗阅读应用(三)

往期传送门: Android+Sqlite 实现古诗阅读应用(一) Android+Sqlite 实现古诗阅读应用(二) 加入截图分享的功能. 很多应用都有分享的功能,我也想在我的古诗App里加入这个功能,单纯的发送文字看起来太逊了,我决定模仿UC浏览器那样发送古诗的截图,使用官方的分享需要授权KEY,太过麻烦所以打算使用系统的分享. 1.在meau里添加这个item: 1 <item 2 android:id="@+id/menu_item_share" 3 android:s

Android+Sqlite 实现古诗阅读应用(二)

传送门:Android+Sqlite 实现古诗阅读应用(一):http://www.cnblogs.com/lfk-dsk/p/4492974.html Hi,又回来了,最近接到很多热情洋溢的小伙伴们的来信,吼开心哈,我会继续努力的=-=! 上回的东西我们做到了有个textview能随机选择诗来进行显示,这也是我做这个东西的初衷,我想找我到底有哪些古诗没有读过,更想感受一下风吹哪页看哪页的闲适(扯远了=-=!),所以功能现在差不多算是结束了, 不过一个古诗应用这么丑可不行,还有就是,我找到了我要

Android SQLite总结(一)

前言 对于Android平台来说,系统内置了丰富的API来供开发人员操作SQLite,我们可以轻松的完成对数据的存取.下面就向大家介绍一下SQLite常用的操作方法.本篇文章主要用到SQLiteDatabase的一些函数.废话少说,直接贴代码!由于数据库中操作的对象时Student类,因此我们看一下Student.java代码: [java]   view plain copy <EMBED id=ZeroClipboardMovie_1 name=ZeroClipboardMovie_1 ty

Android SQLite最简单demo实现(增删查改)

本来不太想写这篇博客的,但是看到网上的关于android数据库操作的博文都讲得很详细,对于像我这样的新手入门了解SQLite的基本操作有一定难度,所以我参考了网上的一些博客文章,并自己亲自摸索了一遍,希望写出这么一篇博文来记录SQLite的最基本操作,同时也希望能够对android的新手们有些帮助. 参考博客:http://www.20864.com/201247/274.html 这里只是一个示范性的demo,并没实现什么具体功能,只实现了对数据库的增删查改操作. 以下是实现demo的步骤:

Android SQLite 的介绍和使用(二)

上一节简单介绍了一下SQLite,这一节我们开始SQLite在Android中的应用. Android提供了一个数据库的帮助类 SQLiteOpenHelper,用于管理数据库的创建和版本管理.我们可以继承这个类,实现它的 onCreate和 onUpgrade方法.我们可以在这里设置数据库的版本,数据库名称,创建数据库表等.下面看代码: public class DBHelper extends SQLiteOpenHelper { //数据库的版本号必须要大于1 public final s

Android SQLite总结(一) (转)

Android SQLite总结(一)  郑海波 2012-08-21 转载请声明:http://blog.csdn.net/nuptboyzhb/article/details/7891887 前言 对于Android平台来说,系统内置了丰富的API来供开发人员操作SQLite,我们可以轻松的完成对数据的存取.下面就向大家介绍一下SQLite常用的操作方法.本篇文章主要用到SQLiteDatabase的一些函数.废话少说,直接贴代码!由于数据库中操作的对象时Student类,因此我们看一下St