I recently published an app on the market. From the developer console, it seems that about 1-2% of my users are faced with this problem. 1-2% are small, but people are more likely to leave comments when something does not work, and not when it happens, which can negatively affect the download.
Unfortunately, the developer console only displays the platform as "different", but my application is available to those who have SDK 1.6+. I also can not recreate this problem, and no user has contacted me directly, so I can not get more information about devices in which it does not work.
Here is the stack
android.database.sqlite.SQLiteException: no such table: QUESTIONS: , while compiling: SELECT * FROM QUESTIONS WHERE DIFFICULTY=2 ORDER BY RANDOM() LIMIT 20 at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91) at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80) at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1434) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1404) at com.app.myapp.db.DBHelper.getQuestionSet(DBHelper.java:140) at com.app.myapp.SplashActivity.getQuestionSetFromDb(SplashActivity.java:109) at com.app.myapp.SplashActivity.onClick(SplashActivity.java:58) at android.view.View.performClick(View.java:2421) at android.view.View$PerformClick.run(View.java:8867) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:5068) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method)
getQuestionSetFromDb (SplashActivity.java:109) refers to
List<Question> questions = myDbHelper.getQuestionSet(diff, numQuestions);
What relates to
public List<Question> getQuestionSet(int difficulty, int numQ){ List<Question> questionSet = new ArrayList<Question>(); Cursor c = myDataBase.rawQuery("SELECT * FROM QUESTIONS WHERE DIFFICULTY=" + difficulty + " ORDER BY RANDOM() LIMIT " + numQ, null); while (c.moveToNext()){
}
Does anyone know a likely cause? It is strange that this happens only with a small number of installations and the inability to determine the level or SDK device that they use makes it difficult.
Any help is appreciated
EDIT: Due to the answers, I include how db is created.
Firstly, my activity has this (this is the same method that causes the crash)
private List<Question> getQuestionSetFromDb() throws Error { int diff = getDifficultySettings(); int numQuestions = getNumQuestions(); DBHelper myDbHelper = new DBHelper(this); try { myDbHelper.createDataBase(); } catch (IOException ioe) { throw new Error("Unable to create database"); } try { myDbHelper.openDataBase(); }catch(SQLException sqle){ throw sqle; } List<Question> questions = myDbHelper.getQuestionSet(diff, numQuestions); myDbHelper.close(); return questions; }
myDBhelper.createdatabase () calls
public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); if(!dbExist) {
checkDatabase ()
private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){
copyDatabase ()
private void copyDataBase() throws IOException{
Variables
private static String DB_PATH = "/data/data/com.app.myapp/databases/"; private static String DB_NAME = "questionsDb"; private SQLiteDatabase myDataBase; private final Context myContext;
Apoliticians, I really should have included this initially