Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieve data from database which contain more than one data
    primarykey
    data
    text
    <p>I want to retrieve data from sqlite. user can have more than 1 score and i want to display it. it can show if user just have only one score, but it shows blank screen if user have more than one score.</p> <p>These are my code</p> <p>ScoreDetailActivity.java</p> <pre><code>public class ScoreDetailActivity extends Activity { protected TextView userName; protected TextView score; protected int user_Id; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.scoredetail); user_Id = getIntent().getIntExtra("USER_ID", 0); SQLiteDatabase db = (new DatabaseUsername(this)).getWritableDatabase(); Cursor cursor = db.rawQuery("SELECT alm._id, alm.nama, alm.jekel, sc._id, sc.score, sc.userId FROM almag alm LEFT OUTER JOIN score sc ON alm._id = sc.userId WHERE alm._id = ?", new String[]{""+user_Id}); if (cursor.getCount() == 1) { cursor.moveToFirst(); userName = (TextView) findViewById(R.id.userName); userName.setText(cursor.getString(cursor.getColumnIndex("nama"))); score = (TextView) findViewById(R.id.score); score.setText(cursor.getString(cursor.getColumnIndex("score"))); } }} </code></pre> <p>scoredetail.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView android:id="@+id/userName" android:layout_width="wrap_content" android:layout_height="wrap_content"/&gt; &lt;TextView android:id="@+id/score" android:layout_width="wrap_content" android:layout_height="wrap_content"/&gt; </code></pre> <p></p> <p>I hope someone can help. Thank you</p>
    singulars
    1. This table or related slice is empty.
    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.
    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