Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLite: library routine called out of sequence - how to resolve this crash?
    text
    copied!<p>Okay, so my app is perfectly working on Android 2.3 and <strong>crashes on 4.0.4.</strong></p> <p>Im parsing an XML and <strong>saving data to my SQLite database.</strong></p> <p>This is not every time happens <strong>but really often</strong>, sometimes on button clicks sometimes on new Activity startups... etc</p> <p>Crash Exception:</p> <pre><code>11-16 15:16:41.231: E/SQLiteQuery(6398): exception: library routine called out of sequence; query: SELECT _id, name, tipus, azonosito, gpsx, gpsy, pictures, telefonok, webcim, email, nyitvatartas, cim, orszag, befogadokepesseg, szolgaltatasok, arkategoria, leiras, ertekeles, pontszam, facebook, keywords, rating FROM shops_top20 11-16 15:16:41.241: E/AndroidRuntime(6398): FATAL EXCEPTION: main 11-16 15:16:41.241: E/AndroidRuntime(6398): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.KeySoft.OpenGuide/com.KeySoft.OpenGuide.Activities.Top20}: android.database.sqlite.SQLiteMisuseException: library routine called out of sequence 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.ActivityThread.access$600(ActivityThread.java:127) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.os.Handler.dispatchMessage(Handler.java:99) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.os.Looper.loop(Looper.java:137) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.ActivityThread.main(ActivityThread.java:4507) 11-16 15:16:41.241: E/AndroidRuntime(6398): at java.lang.reflect.Method.invokeNative(Native Method) 11-16 15:16:41.241: E/AndroidRuntime(6398): at java.lang.reflect.Method.invoke(Method.java:511) 11-16 15:16:41.241: E/AndroidRuntime(6398): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978) 11-16 15:16:41.241: E/AndroidRuntime(6398): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) 11-16 15:16:41.241: E/AndroidRuntime(6398): at dalvik.system.NativeStart.main(Native Method) 11-16 15:16:41.241: E/AndroidRuntime(6398): Caused by: android.database.sqlite.SQLiteMisuseException: library routine called out of sequence 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.database.sqlite.SQLiteQuery.nativeFillWindow(Native Method) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:86) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:201) 11-16 15:16:41.241: E/AndroidRuntime(6398): at com.KeySoft.OpenGuide.Activities.Top20.SqlShopsVissza(Top20.java:546) 11-16 15:16:41.241: E/AndroidRuntime(6398): at com.KeySoft.OpenGuide.Activities.Top20.listakKirajzolasaEsValtas(Top20.java:165) 11-16 15:16:41.241: E/AndroidRuntime(6398): at com.KeySoft.OpenGuide.Activities.Top20.onCreate(Top20.java:113) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.Activity.performCreate(Activity.java:4469) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052) 11-16 15:16:41.241: E/AndroidRuntime(6398): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932) </code></pre> <p><strong>E D I T : Ok, so i closed all the cursors just before i close all the db connections in my app, and NOW i got this excption:</strong></p> <pre><code> 11-16 20:00:28.409: E/AndroidRuntime(7548): FATAL EXCEPTION: main 11-16 20:00:28.409: E/AndroidRuntime(7548): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.KeySoft.OpenGuide/com.KeySoft.OpenGuide.Activities.Top20}: java.util.ConcurrentModificationException 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.ActivityThread.access$600(ActivityThread.java:127) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.os.Handler.dispatchMessage(Handler.java:99) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.os.Looper.loop(Looper.java:137) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.ActivityThread.main(ActivityThread.java:4507) 11-16 20:00:28.409: E/AndroidRuntime(7548): at java.lang.reflect.Method.invokeNative(Native Method) 11-16 20:00:28.409: E/AndroidRuntime(7548): at java.lang.reflect.Method.invoke(Method.java:511) 11-16 20:00:28.409: E/AndroidRuntime(7548): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978) 11-16 20:00:28.409: E/AndroidRuntime(7548): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) 11-16 20:00:28.409: E/AndroidRuntime(7548): at dalvik.system.NativeStart.main(Native Method) 11-16 20:00:28.409: E/AndroidRuntime(7548): Caused by: java.util.ConcurrentModificationException 11-16 20:00:28.409: E/AndroidRuntime(7548): at java.util.WeakHashMap$HashIterator.next(WeakHashMap.java:165) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.database.sqlite.SQLiteDatabase.closeClosable(SQLiteDatabase.java:1250) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.database.sqlite.SQLiteDatabase.close(SQLiteDatabase.java:1220) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.database.sqlite.SQLiteOpenHelper.close(SQLiteOpenHelper.java:265) 11-16 20:00:28.409: E/AndroidRuntime(7548): at com.KeySoft.OpenGuide.DB_Adapter.close(DB_Adapter.java:273) 11-16 20:00:28.409: E/AndroidRuntime(7548): at com.KeySoft.OpenGuide.Activities.Top20.SqlShopsVissza(Top20.java:558) 11-16 20:00:28.409: E/AndroidRuntime(7548): at com.KeySoft.OpenGuide.Activities.Top20.listakKirajzolasaEsValtas(Top20.java:165) 11-16 20:00:28.409: E/AndroidRuntime(7548): at com.KeySoft.OpenGuide.Activities.Top20.onCreate(Top20.java:113) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.Activity.performCreate(Activity.java:4469) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052) 11-16 20:00:28.409: E/AndroidRuntime(7548): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932) </code></pre> <p><strong>The problematic part in my code, is a function in my Top20 Activity, which is currently the following function:</strong></p> <pre><code>protected void getShopsFromSql(String whichTable){ db.open(); Cursor c; if(whichTable.equals("Top20")){ c = db.getAllTop20Titles(); } else if (whichTable.equals("Latest10")){ c = db.getAllLatest10Titles(); } else{ c = db.getAllShopsFullTitles(); } if (c.moveToFirst()) { do { addShopToList(c.getString(1), c.getString(2), c.getString(4), c.getString(5), c.getString(12), c.getString(11), c.getString(3)); }while (c.moveToNext()); } c.close(); db.close(); //App Crashes here... why? } </code></pre> <p>db is my Database for sure, I Googled this error and of course it happens when i want to edit a value on a thread and iterate throu the same value by an other thread (background AsyncTask this time), but i have a singleton Database Adapter and i read here in stack that this kind of Database implementation is the best for Android apps.</p> <p>I have an extended Application class with a single database and i call each and every time this database.</p> <pre><code>public class MyApp extends Application { private static DB_Adapter globalDatabase; @Override public void onCreate() { super.onCreate(); globalDatabase = new DB_Adapter(this); } public static DB_Adapter getDB() { return globalDatabase; } </code></pre> <p>}</p> <p>Reference to the database in my apps like this:</p> <pre><code>public class Top20 extends Activity { private DB_Adapter db; private MyApp myApp; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.top20); myApp = (MyApp) getApplication(); db = myApp.getDB(); //...........morecode...etc.. </code></pre> <p>SO:</p> <p>My questions are:</p> <p>Why is this error occured? Am I doing right this singleton database implementation? </p> <p>Thanks your advices, Adam</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload