Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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 Sqlite资产助手:没有这样的列错误_Android_Sqlite_Android Sqlite - Fatal编程技术网

Android Sqlite资产助手:没有这样的列错误

Android Sqlite资产助手:没有这样的列错误,android,sqlite,android-sqlite,Android,Sqlite,Android Sqlite,我使用了SQLITEDB浏览器并创建了 数据库:harryPotterDB.db 表名:PotterQuizCollection(问题,选项1,Ans,QID) 数据库位于assets/databases/harryPotterDB.db中 发生的错误是 android.database.sqlite.SQLiteException:没有这样的列:Ans:,编译时:从PotterQuizCollection中选择0\u id,Question,Option1,Ans我可以访问Option1和Qu

我使用了SQLITEDB浏览器并创建了
数据库:harryPotterDB.db
表名:PotterQuizCollection(问题,选项1,Ans,QID)

数据库位于assets/databases/harryPotterDB.db中

发生的错误是 android.database.sqlite.SQLiteException:没有这样的列:Ans:,编译时:从PotterQuizCollection中选择0\u id,Question,Option1,Ans我可以访问Option1和Question列

SQLiteDBHandler.java

LOGCAT


卸载并重新安装应用程序,或者使用“设置”中的“清除”应用程序上的数据,强制您从一个新的数据库开始,然后查看它是否有效。如果是这样,那么您添加了
Ans
列,但您已经在设备上有一个数据库,其中一个表缺少该列。您是否将数据库复制到/data/data/package/database/
选择0\u id,问题,选项1,选项2,选项3,来自PotterQuizCollection的Ans
。。。选择0 _id。。。?!错误在这里:
String[]sqlSelect={“0\u id”,“疑问”,“选项1”,“Ans”}
Commonware和Frank N.Stein都指出了问题所在,那就是我使用的是陈旧/旧的数据库,所有需要做的都是手机上应用程序的清晰数据,卸载也会解决问题,感谢帮助:)
                package com.example.sandeep.harrypotterquiz;

                import android.content.Context;
                import android.database.Cursor;
                import android.database.sqlite.SQLiteDatabase;
                import android.database.sqlite.SQLiteQueryBuilder;
                import android.util.Log;

                import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;

                public class SQLiteDBHandler extends SQLiteAssetHelper
                {
                    private static final String TAG = "mytag";
                    private static final String DATABASE_NAME = "harryPotterDB.db";
                    private static final int DATABASE_VERSION = 1;

                    public SQLiteDBHandler(Context context)
                    {
                        super(context, DATABASE_NAME, null, DATABASE_VERSION);
                    }


                    public  void/*String[]*/  getQuestion(int qCounter)
                    {
                        /**********VARIABLE SECTION STARTS************/
                        SQLiteDatabase db = getReadableDatabase();
                        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
                        String questionDetails[]=new String[6];
                        int arrayPtr=0;
                        /**********VARIABLE SECTION ENDS************/

                        String [] sqlSelect = {"0 _id","Question","Option1","Ans"};
                        String sqlTables = "PotterQuizCollection";

                        qb.setTables(sqlTables);
                        Log.d(TAG, "just before cursor");
                        Cursor c = qb.query(db, sqlSelect, null, null,
                                null, null, null);

                        Log.d(TAG, "just after cursor");
                        /****************************DATABASE ACCESS SECTION DONE. WE HAVE CURSOR C WITH US********************************************/

                        c.moveToFirst();
                        Log.d(TAG, c.getString(2));
                        /*
                    }
                }
09-26 17:49:35.726  13487-13487/com.example.sandeep.harrypotterquiz I/Database? sqlite returned: error code = 1, msg = no such column: Ans
          09-26 17:49:35.742  13487-13487/com.example.sandeep.harrypotterquiz E/AndroidRuntime? FATAL EXCEPTION: main
          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sandeep.harrypotterquiz/com.example.sandeep.harrypotterquiz.QuizDisplay}: android.database.sqlite.SQLiteException: no such column: Ans: , while compiling: SELECT 0 _id, Question, Option1, Option2, Option3, Ans FROM PotterQuizCollection
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
          at android.app.ActivityThread.access$1500(ActivityThread.java:117)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:130)
          at android.app.ActivityThread.main(ActivityThread.java:3689)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:507)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
          at dalvik.system.NativeStart.main(Native Method)