android - Row from Database Cant be Display -
for many times, have encountered problem , need help. im trying id data activity , pass activity, , works. problem there no error data id, passed second activity wont show. here first activity :
lv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> 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); }});
and here second activity :
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 = z.getstring(z.getcolumnindex("product")); xview.settext(a); db.close(); }
i've got no error force closed.... clue ???
this db.getlist
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 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) > 0; } }
logcat show nothing useful think...
07-31 15:26:26.049: w/dalvikvm(20436): threadid=1: thread exiting 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 start activity componentinfo{com.test.first/com.test.first.pdetail}: android.database.cursorindexoutofboundsexception: index 0 requested, size of 0 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.activitythread.access$1500(activitythread.java:117) 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.activitythread$h.handlemessage(activitythread.java:935) 07-31 15:26:26.049: e/androidruntime(20436): @ android.os.handler.dispatchmessage(handler.java:99) 07-31 15:26:26.049: e/androidruntime(20436): @ android.os.looper.loop(looper.java:130) 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.activitythread.main(activitythread.java:3687) 07-31 15:26:26.049: e/androidruntime(20436): @ java.lang.reflect.method.invokenative(native method) 07-31 15:26:26.049: e/androidruntime(20436): @ java.lang.reflect.method.invoke(method.java:507) 07-31 15:26:26.049: e/androidruntime(20436): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:867) 07-31 15:26:26.049: e/androidruntime(20436): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:625) 07-31 15:26:26.049: e/androidruntime(20436): @ dalvik.system.nativestart.main(native method) 07-31 15:26:26.049: e/androidruntime(20436): caused by: android.database.cursorindexoutofboundsexception: index 0 requested, size of 0 07-31 15:26:26.049: e/androidruntime(20436): @ android.database.abstractcursor.checkposition(abstractcursor.java:580) 07-31 15:26:26.049: e/androidruntime(20436): @ android.database.abstractwindowedcursor.checkposition(abstractwindowedcursor.java:214) 07-31 15:26:26.049: e/androidruntime(20436): @ android.database.abstractwindowedcursor.getstring(abstractwindowedcursor.java:41) 07-31 15:26:26.049: e/androidruntime(20436): @ com.test.first.pdetail.get(pdetail.java:32) 07-31 15:26:26.049: e/androidruntime(20436): @ com.test.first.pdetail.oncreate(pdetail.java:18) 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 07-31 15:26:26.049: e/androidruntime(20436): @ android.app.activitythread.performlaunchactivity(activitythread.java:1615) 07-31 15:26:26.049: e/androidruntime(20436): ... 11 more
Comments
Post a Comment