Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android E/SQLiteLog:(1)近;“全部”:语法错误_Android_Sql_Sqlite_Syntax Error - Fatal编程技术网

Android E/SQLiteLog:(1)近;“全部”:语法错误

Android E/SQLiteLog:(1)近;“全部”:语法错误,android,sql,sqlite,syntax-error,Android,Sql,Sqlite,Syntax Error,我是应用程序开发新手,正在尝试构建一个应用程序,该应用程序搜索名为“All”的数据库表,但不断出现以下错误: E/SQLiteLog: (1) no such table: FullBook E/SQLiteLog:(1)接近“全部”:语法错误 错误代码:1(SQLITE_错误) 原因:SQL(查询)错误或缺少数据库。 (接近“全部”:语法错误(代码1):,编译时:从全部中选择短语) 我想这一定是我的数据库设置有问题,但找不到故障 这是我的密码: public class Database e

我是应用程序开发新手,正在尝试构建一个应用程序,该应用程序搜索名为“All”的数据库表,但不断出现以下错误:

E/SQLiteLog: (1) no such table: FullBook
E/SQLiteLog:(1)接近“全部”:语法错误

错误代码:1(SQLITE_错误) 原因:SQL(查询)错误或缺少数据库。 (接近“全部”:语法错误(代码1):,编译时:从全部中选择短语)

我想这一定是我的数据库设置有问题,但找不到故障

这是我的密码:

public class Database extends SQLiteAssetHelper {
    private static final String DB_NAME="DoYouGetMeDoc.db";
    private static final int DB_VER=1;
    public Database(Context context) {
        super(context, DB_NAME, null, DB_VER);
    }

    public List<Items> getall(){
        SQLiteDatabase db = getReadableDatabase();
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        String[] sqliteSelect={"Phrase","Description","Example", "Chapter"};
        String tableName="All";
        qb.setTables(tableName);
        Cursor cursor = qb.query(db,sqliteSelect,null,null,null,null,null);
        List<Items> results = new ArrayList<>();
        if (cursor.moveToFirst()){
            do {
                Items items = new Items();
                items.setPhrase(cursor.getString(cursor.getColumnIndex("Phrase")));
                items.setDescription(cursor.getString(cursor.getColumnIndex("Description")));
                items.setExample(cursor.getString(cursor.getColumnIndex("Example")));
                items.setChapter(cursor.getString(cursor.getColumnIndex("Chapter")));
                results.add(items);
            }while (cursor.moveToNext());
        }
        return results;
    }

    public List<String> getPhrases(){
        SQLiteDatabase db = getReadableDatabase();
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        String[] sqliteSelect={"Phrase"};
        String tableName="All";
        qb.setTables(tableName);
        Cursor cursor = qb.query(db,sqliteSelect,null,null,null,null,null);
        List<String> results = new ArrayList<>();
        if (cursor.moveToFirst()){
            do {
                results.add(cursor.getString(cursor.getColumnIndex("Phrase")));
            }while (cursor.moveToNext());
        }
        return results;

    }

    public List<Items> getPhrasesbyPhrase(String phrase)
    {
        SQLiteDatabase db = getReadableDatabase();
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        String[] sqliteSelect={"Phrase","Description","Example","Chapter"};
        String tableName="All";
        qb.setTables(tableName);
        Cursor cursor = qb.query(db,sqliteSelect,"Phrase like ?",new String[]{"%"+phrase+"%"},null,null,null);
        List<Items> results = new ArrayList<>();
        if (cursor.moveToFirst()){
            do {
                Items items = new Items();
                items.setPhrase(cursor.getString(cursor.getColumnIndex("Phrase")));
                items.setDescription(cursor.getString(cursor.getColumnIndex("Description")));
                items.setExample(cursor.getString(cursor.getColumnIndex("Example")));
                items.setChapter(cursor.getString(cursor.getColumnIndex("Chapter")));
                results.add(items);
            }while (cursor.moveToNext());
        }
        return results;
    } }

ALL
是SQLite和所有(我相信)rdms的关键字(保留字)
并且不能将其用作表的名称
在这里您可以看到SQLite的所有保留字:


如果您坚持使用它,您可以将它括在方括号中,如
[All]

嗨,Rehman,All是SQLLITE中的保留关键字(请参阅)。我将尝试重新命名您的表,然后重试。我将表的标题更改为“FullBook”,但现在收到一个新错误/SQLiteLog:(1)没有这样的表:FullBook从模拟器/设备卸载应用程序。在assets文件夹中复制一个新版本的db,其中包含具有新名称的新表,然后重新开始。