Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see a problem that on your Android SQLite <code>CREATE_LOGIN_TABLE</code> statement, there is no creation of column <code>encrypted_password</code>. Then your table has only 11 columns which leads to maximum index 10. There is no column with index 11 and no column with name <code>encrypted_password</code> and calling <code>cursor.getString(11);</code> is the reason of error which force closes your application.</p> <p><strong>Problem of all your reading of database data are hard coded indexes which do not match order of created columns.</strong> When you create your table on your <code>onCreateDatabase()</code> method, column order is: </p> <ol> <li>id</li> <li>fname</li> <li>lname</li> <li>email </li> </ol> <p>etc. due to order of column names in create table statement.</p> <p>Than in your <code>getUserDetails</code> method, you are taking fname with index 5, lname with index 6 etc. hard coded indexes does not match the order of columns in create table statement and you take username and id values instead of fname and lname. Simmilar it is for other columns.</p> <p>For properly work with column indexes, you should use <code>getColumnIndex(String columnName)</code> method on <code>Cursor</code> instead of hard coded indexes. For example:</p> <pre><code>int fnameIndex = cursor.getColumnIndex(KEY_FIRSTNAME); String fname = cursor.getString(fnameIndex); </code></pre> <p>Here is snippet of code you could use in your <code>getUserDetails()</code> method:</p> <pre><code> user.put("id", cursor.getString(cursor.getColumnIndex(KEY_ID))); // id - uid user.put("username", cursor.getString(cursor.getColumnIndex(KEY_USERNAME))); // uname - username user.put("email", cursor.getString(cursor.getColumnIndex(KEY_EMAIL))); user.put("fname", cursor.getString(cursor.getColumnIndex(KEY_FIRSTNAME))); user.put("lname", cursor.getString(cursor.getColumnIndex(KEY_LASTNAME))); user.put("dob", cursor.getString(cursor.getColumnIndex(KEY_DATEOFBIRTH))); user.put("tel", cursor.getString(cursor.getColumnIndex(KEY_TELEPHONE))); user.put("address", cursor.getString(cursor.getColumnIndex(KEY_ADDRESS))); user.put("ptc", cursor.getString(cursor.getColumnIndex(KEY_CREATED_AT))); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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