title: ERROR: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is correctly initialized before accessing data
body: <p>I have created a very <strong>simple database</strong> android app. It takes an input and display result. Add button is used to add the input and delete button for deleting the input stored in SQLite database. My <strong>cursor</strong> in Android SQLite is pointed correctly but still I am facing the error: <strong>Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.</strong> Following is the cursor part:
  Cursor c = db.rawQuery(query, null);</p>
  
  <pre><code>    c.moveToFirst();
  
      //Traversing through DB
      while (!c.isAfterLast()){
          if(c.getString(c.getColumnIndex("studentname")) !=null)
          {
              dbString += c.getString(c.getColumnIndex("studentname"));
              dbString +="\n"; }
  
          c.moveToNext(); }
          db.close();
  
          return dbString;
  </code></pre>
  
  <p>I have tried changing cursor positions but still same error appearing. I have researched on other sites and same is the concept but still there is an issue.</p>