title: Reading from SQLite database causes stack overflow
body: <p>Can't find the problem with why the SQLite database cannot be read, it's taken me so long and I still can't figure out why trying to read from it is giving me stack Overflow, appreciate all help, thank you.    </p>
  
  <pre><code>public class DatabaseHandler extends SQLiteOpenHelper {
  
  
  private static Context ctx;
  
  
  // All Static variables
  // Database Version
  private static final int DATABASE_VERSION = 1;
  
  // Database Name
  private static final String DATABASE_NAME = "chirhogs_android_api";
  
  // Login table name
  private static final String TABLE_LOGIN = "fusers";
  
  // Login Table Columns names
  private static final String KEY_ID = "id";
  public static final String KEY_NAME = "name";
  public static final String KEY_EMAIL = "email";
  private static final String KEY_UID = "uid";
  private static final String KEY_CREATED_AT = "created_at";
  
  public DatabaseHandler(Context ctx) {
      super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
      this.ctx = ctx;
  
  }
  
  DatabaseHandler jhelper = new DatabaseHandler(ctx.getApplicationContext());
  
  // Creating Tables
  @Override
  public void onCreate(SQLiteDatabase db) {
      String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
              + KEY_ID + " INTEGER PRIMARY KEY," 
              + KEY_NAME + " TEXT,"
              + KEY_EMAIL + " TEXT UNIQUE,"
              + KEY_UID + " TEXT,"
              + KEY_CREATED_AT + " TEXT " + ");";
      db.execSQL(CREATE_LOGIN_TABLE);
  }
  
  // Upgrading database
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      // Drop older table if existed
      db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
  
      // Create tables again
      onCreate(db);
  }
  
  /**
   * Storing user details in database
   * */
  public void addUser(String name, String email, String uid, String created_at) {
      SQLiteDatabase db = jhelper.getWritableDatabase();
  
      ContentValues values = new ContentValues();
      values.put(KEY_NAME, name); // Name
      values.put(KEY_EMAIL, email); // Email
      values.put(KEY_UID, uid); // Email
      values.put(KEY_CREATED_AT, created_at); // Created At
  
      // Inserting Row
      db.insert(TABLE_LOGIN, null, values);
       // Closing database connection
  }
  
  /**
   * Getting user data from database
   * */
  public HashMap&lt;String, String&gt; getUserDetails(){
      HashMap&lt;String,String&gt; user = new HashMap&lt;String,String&gt;();
      String selectQuery = "SELECT  * FROM " + TABLE_LOGIN + " ORDER BY "+KEY_CREATED_AT+" DESC LIMIT 1";
  
      SQLiteDatabase db = jhelper.getReadableDatabase();
  
      Cursor cursor = db.rawQuery(selectQuery, null);
      // Move to first row
      cursor.moveToFirst();
      if(cursor.getCount() &gt; 0){
          user.put("name", cursor.getString(1));
          user.put("email", cursor.getString(2));
          user.put("uid", cursor.getString(3));
          user.put("created_at", cursor.getString(4));
      }
      cursor.close();
      db.close();
      // return user
      return user;
  }
  
  /**
   * Getting user login.xml status
   * return true if rows are there in table
   * */
  public int getRowCount() {
      String countQuery = "SELECT  * FROM " + TABLE_LOGIN;
      SQLiteDatabase db = jhelper.getReadableDatabase();
      Cursor cursor = db.rawQuery(countQuery, null);
      int rowCount = cursor.getCount();
  
      cursor.close();
  
      // return row count
      return rowCount;
  }
  </code></pre>
  
  <p>When I run this it gives me stack over flow and closes the application, I have checked the SQLite database and the data is written correctly, it's just the reading which is the issue.</p>
  
  <p>Here is the log:</p>
  
  <pre><code>05-29 15:15:59.827    3191-3191/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: abelabs.dank, PID: 3191
  java.lang.StackOverflowError: stack size 8MB
          at android.database.sqlite.SQLiteOpenHelper.&lt;init&gt;(SQLiteOpenHelper.java:77)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:35)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.dank.library.DatabaseHandler.&lt;init&gt;(DatabaseHandler.java:38)
          at abelabs.
  </code></pre>