Note that there are some explanatory texts on larger screens.

plurals
  1. PORow from Database Cant be Display
    primarykey
    data
    text
    <p>For many times, i have encountered another problem and need your help. Im trying to get an id data from an activity and pass it to another activity, and it works. The problem is there is no error but my data from a certain id, i passed to the second activity wont show. Here is my first activity :</p> <pre><code>lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,long arg3) { // Intent newI = new Intent(this,PDetail.class); Intent newI = new Intent (Create.this, PDetail.class); newI.putExtra("value", arg3); startActivity (newI); // db.getList(arg3); }}); </code></pre> <p>and here is my second activity :</p> <pre><code> public void get() { Bundle bundle = getIntent().getExtras(); long count = bundle.getLong("value"); TextView XView; //Toast.makeText(getApplicationContext(), count, Toast.LENGTH_SHORT).show(); XView = (TextView) findViewById(R.id.textView1); //XView.setText("Number: " + count); db.open(); Cursor z = db.getList(count); z.moveToFirst(); String a = z.getString(z.getColumnIndex("product")); XView.setText(a); db.close(); } </code></pre> <p>I've got no error but it just force closed.... Any clue ???</p> <p>This is the db.getList</p> <pre><code>public Cursor getList(long rowId) throws SQLException { Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_PRODUCT,KEY_BRAND, KEY_PLACE, KEY_DATE, KEY_PRICE}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } //---updates a contact--- public boolean updateList(long rowId, String product, String brand, String place, String date, String price) { ContentValues args = new ContentValues(); args.put(KEY_PRODUCT, product); args.put(KEY_BRAND, brand); args.put(KEY_PLACE, place); args.put(KEY_DATE, date); args.put(KEY_PRICE, price); return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) &gt; 0; } } </code></pre> <p>Logcat show nothing useful i think...</p> <pre><code>07-31 15:26:26.049: W/dalvikvm(20436): threadid=1: thread exiting with uncaught exception (group=0x40018578) 07-31 15:26:26.049: E/AndroidRuntime(20436): FATAL EXCEPTION: main 07-31 15:26:26.049: E/AndroidRuntime(20436): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.first/com.test.first.PDetail}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.os.Handler.dispatchMessage(Handler.java:99) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.os.Looper.loop(Looper.java:130) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.ActivityThread.main(ActivityThread.java:3687) 07-31 15:26:26.049: E/AndroidRuntime(20436): at java.lang.reflect.Method.invokeNative(Native Method) 07-31 15:26:26.049: E/AndroidRuntime(20436): at java.lang.reflect.Method.invoke(Method.java:507) 07-31 15:26:26.049: E/AndroidRuntime(20436): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 07-31 15:26:26.049: E/AndroidRuntime(20436): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 07-31 15:26:26.049: E/AndroidRuntime(20436): at dalvik.system.NativeStart.main(Native Method) 07-31 15:26:26.049: E/AndroidRuntime(20436): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41) 07-31 15:26:26.049: E/AndroidRuntime(20436): at com.test.first.PDetail.get(PDetail.java:32) 07-31 15:26:26.049: E/AndroidRuntime(20436): at com.test.first.PDetail.onCreate(PDetail.java:18) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 07-31 15:26:26.049: E/AndroidRuntime(20436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 07-31 15:26:26.049: E/AndroidRuntime(20436): ... 11 more </code></pre>
    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.
 

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