sqlite - how to solve RunTime error with imageView in android -


i still have problem body help?? please don't have time. tommorow last graduate project presentation.

(java.lang.runtimeexception: unable start activity componentinfo{com.example.assfar/com.example.assfar.hotel.hotel_details}: java.lang.nullpointerexception 

i got run time error start activity

package com.example.assfar.hotel;  import android.app.activity; import android.content.intent; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.imageview; import android.widget.textview;  import com.example.assfar.r; import com.example.assfar.database.dbhelper; import com.example.assfar.offers.customer_info;   public class hotel_details extends activity{      private dbhelper database;     private imageview imgv;     private textview textview;     private textview textview2;     private textview textview3;     private cursor cursor;     private string price;     private string hoteldesc;     private int idvalue;     private byte [] imgbyte;       @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.hotel_details);          textview = (textview)findviewbyid(r.id.hotel_name);         textview2 = (textview)findviewbyid(r.id.hotel_desc);         textview3 = (textview)findviewbyid(r.id.hotel_price);          imgv = (imageview)findviewbyid(r.id.hotel_image);         imgv.setimagedrawable(null);          intent i= getintent();         // getting attached intent data         string item = i.getstringextra("selected item");         int id = i.getintextra("hotel_id", 1);           // displaying selected product name           textview.settext(item);         imgbyte= null;         database=  dbhelper.instance();         sqlitedatabase db= database.getwritabledatabase();          cursor= db.rawquery("select * hotel_reservation", null);          if(cursor!=null) {              if(cursor.movetofirst());              {                                  {                   price = cursor.getstring(cursor.getcolumnindex("price"));                  idvalue= cursor.getint(cursor.getcolumnindex("reservationid"));                  hoteldesc= cursor.getstring(cursor.getcolumnindex("hotel_description"));                                                                  imgbyte= cursor.getblob(cursor.getcolumnindex("hotel_photo"));                  bitmap bmp = bitmapfactory.decodebytearray(imgbyte,0,imgbyte.length);                       if(idvalue==id){                         textview2.settext("\n"+hoteldesc);                       imgv.setimagebitmap(bmp);                        }                   } while(cursor.movetonext());              }         }           button butt_reserve= (button)findviewbyid(r.id.reserve);         butt_reserve.setonclicklistener(new onclicklistener(){              @override             public void onclick(view v) {                 intent i=new intent(hotel_details.this,customer_info.class);                 startactivity(i);                                }          });         } } 

logcat

 05-19 16:53:32.411: e/androidruntime(3661): fatal exception: main     05-19 16:53:32.411: e/androidruntime(3661): java.lang.runtimeexception: unable start activity componentinfo{com.example.assfar/com.example.assfar.hotel.hotel_details}: java.lang.nullpointerexception     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2180)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activitythread.access$600(activitythread.java:141)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activitythread$h.handlemessage(activitythread.java:1234)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.os.handler.dispatchmessage(handler.java:99)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.os.looper.loop(looper.java:137)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activitythread.main(activitythread.java:5041)     05-19 16:53:32.411: e/androidruntime(3661):     @ java.lang.reflect.method.invokenative(native method)     05-19 16:53:32.411: e/androidruntime(3661):     @ java.lang.reflect.method.invoke(method.java:511)     05-19 16:53:32.411: e/androidruntime(3661):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793)     05-19 16:53:32.411: e/androidruntime(3661):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560)     05-19 16:53:32.411: e/androidruntime(3661):     @ dalvik.system.nativestart.main(native method)     05-19 16:53:32.411: e/androidruntime(3661): caused by: java.lang.nullpointerexception     05-19 16:53:32.411: e/androidruntime(3661):     @ com.example.assfar.hotel.hotel_details.oncreate(hotel_details.java:74)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activity.performcreate(activity.java:5104)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080)     05-19 16:53:32.411: e/androidruntime(3661):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2144)     05-19 16:53:32.411: e/androidruntime(3661):     ... 11 more 

check make sure you've registered activity in manifest. common cause of kind of error.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -