title: Android database CursorIndexOutOfBoundsException only on device
body: <p>I have trouble with my app, when i'm trying to get active user from the database. Here is my code from the function. </p>
  
  <pre><code>public String getActiveChild(){
      Cursor cur = database.query(true, TABLE_CHILDREN, null, "status = 1", null, null,
              null, null, null);
      Log.v("test4e",cur.getCount()+" count");
      cur.moveToFirst();
      Log.v("test", cur.getString(cur.getColumnIndex("name")));
      return cur.getString(cur.getColumnIndex("name"));
  }
  </code></pre>
  
  <p>This works perfectly on the emulator but when i test it on a device it gives me this error in logcat.</p>
  
  <pre><code> 04-03 11:51:02.362: E/AndroidRuntime(961): FATAL EXCEPTION: main
  04-03 11:51:02.362: E/AndroidRuntime(961): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.myapp/com.app.myapp.SettingsActivity}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.ActivityThread.access$1500(ActivityThread.java:123)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.os.Handler.dispatchMessage(Handler.java:99)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.os.Looper.loop(Looper.java:130)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.ActivityThread.main(ActivityThread.java:3835)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at java.lang.reflect.Method.invokeNative(Native Method)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at java.lang.reflect.Method.invoke(Method.java:507)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at dalvik.system.NativeStart.main(Native Method)
  04-03 11:51:02.362: E/AndroidRuntime(961): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at com.app.myyapp.DatabaseHelper.getActiveChild(DatabaseHelper.java:168)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at com.app.myyapp.SettingsActivity.init(SettingsActivity.java:61)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at com.app.myyapp.SettingsActivity.onCreate(SettingsActivity.java:50)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  04-03 11:51:02.362: E/AndroidRuntime(961):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
  </code></pre>