Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your problem is that you are not using the <code>SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to)</code> correctly. You have <code>from</code> array containing the columns you want to show from the table and the <code>to</code> array should contain the views to show the columns to. </p> <p>You should have number of fields in <code>to</code> equals to <code>from</code>, else you will have the behaviour you have which is only the first column in <code>from</code> is mapped to <code>R.id.item_text</code>. </p> <p><strong>Update:</strong></p> <p>Since you only want to show the name column to show, then do not use the ListView to fill the cursor <code>cursor = (Cursor) listView.getItemAtPosition(position);</code>. You should replace:</p> <pre><code>Cursor cursor = (Cursor) listView.getItemAtPosition(position); </code></pre> <p>with:</p> <pre><code>Cursor cursor = DatabaseSetup.getContactData(); StartManagingCursor(cursor); cursor.moveToFirst(); </code></pre> <p>Since you use this <code>cursor</code> later to fill the values passed to the other Activity, you can't get it from <code>listView.getItemAtPosition(position);</code> because there is only one item at position <code>position</code> (which is the name column), so the other items give <code>NullPointerException</code> as they do not exist in the <code>cursor</code> returned from <code>listView.getItemAtPosition(position);</code></p> <p><strong>Update 2:</strong></p> <p>Also:</p> <pre><code>setName(selectedName); setName(selectedEmail); setName(selectedPhone1); setName(selectedPhone2); setName(selectedAddress); setName(selectedNotes); </code></pre> <p>Should be:</p> <pre><code>setName(selectedName); setEmail(selectedEmail); setPhone1(selectedPhone1); setPhone2(selectedPhone2); setAddress(selectedAddress); setNotes(selectedNotes); </code></pre>
 

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