java - Capture Image Display it on ImageView and save images in SD card with different serial number -


i have added following code camera activity, code works fine creates 1 image in directory. want add more images sequence image.1.jpg,image.2.jpg , on. how should this. kindly suggest.

public class camera extends appcompatactivity {             imagebutton image_button;             imageview image_view;             static final int camera_request = 1;              @override             protected void oncreate(bundle savedinstancestate) {                 super.oncreate(savedinstancestate);                 setcontentview(r.layout.activity_camera);                 image_button= (imagebutton)findviewbyid(r.id.imagebutton);                 image_view= (imageview)findviewbyid(r.id.imageview8);                 image_button.setonclicklistener(new view.onclicklistener() {                     @override                     public void onclick(view v) {                         intent intent = new intent(mediastore.action_image_capture);                         file file = getfile();                         intent.putextra(mediastore.extra_output, uri.fromfile(file));                         startactivityforresult(intent, camera_request);                     }                 });              }             private file getfile()             {                 file folder = new file("sdcard/3d_try");                 if (!folder.exists())                 {                     folder.mkdir();                 }                  file imagefile = new file(folder,"image.jpg");                 return imagefile;             }         @override             protected void onactivityresult(int requestcode, int resultcode, intent data) {                 string path = "sdcard/3d_try/image.jpg";                 image_view.setimagedrawable(drawable.createfrompath(path));             }         } 

replace line

file imagefile = new file(folder, "image.jpg"); 

from

string imagename = string.valueof(system.currenttimemillis()) + ".jpg"; file imagefile = new file(folder, imagename); 

Comments