android - Get PicturePath selected from gallery to store it in dataBase -


i used code upload image gallery .it works perfectly..but problem wanna image's path store in wamp database ..`

public class image extends activity { imageview contact;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_image);       contact = (imageview) findviewbyid(r.id.candidat);     contact.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             intent intent = new intent();             intent.settype("image/*");             intent.setaction(intent.action_get_content);             startactivityforresult(intent.createchooser(intent, "select     contact image"), 1);           }     }); }  public void onactivityresult(int reqcode, int rescode, intent data) {       if (rescode == result_ok) {          if (reqcode == 1)             contact.setimageuri(data.getdata());       }   }    }  

thank help

you can exact path using method -

public string getpathfromuri(uri contenturi) {     string result = null;     cursor cursor = getcontentresolver().query(contenturi, null, null, null, null);     if (cursor != null) {         cursor.movetofirst();          int _id = cursor.getcolumnindex(mediastore.images.imagecolumns.data);          result = cursor.getstring(_id);         cursor.close();     }     return result; } 

and use -

public void onactivityresult(int reqcode, int rescode, intent data) {     if (rescode == result_ok) {          if (reqcode == 1)             contact.setimageuri(data.getdata());            string path = getpathfromuri(data.getdata());     } } 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -