title: How to get the total count of records from SQLite
body: <p>I am trying to get the total count of rows from Sqlite DB. Following is the code snippet of what I am trying to do. </p>
  
  <p>I dont know what I am doing wrong here ?</p>
  
  <pre><code>public static int getTotalCount(Context _context)
  {
  Cursor c = null;
  try
  {
      c = getInstance(_context).db.rawQuery("SELECT COUNT(word) FROM  "
          + WORD_TABLE, null);
  
      return c.getInt(c.getColumnIndex(WORD_COL));
  
  } catch (Exception e)
  {
      Log.e("getTotalCount", e.toString());
  }
  return 0;
  </code></pre>
  
  <p>Exception message :
  05-08 05:21:19.934: ERROR/getTotalCount(440): android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1</p>
  
  <p><img src="https://i.stack.imgur.com/SDddR.jpg" alt="enter image description here"></p>