arrays - Android Studio: Need to add several edit text and an image to a file in external storage -


i got showroom application admin can add car show. design ready. need store values given in simple file file going stored in external storage of device. code:

i declared buttons , edit text:

public edittext make; public edittext model; public edittext year; public edittext price; public edittext trans; public edittext color; public button addcar; public button uploadimg; public button cancel;  string[] toaddcar = {         make.gettext().tostring(),         model.gettext().tostring(),         year.gettext().tostring(),         price.gettext().tostring(),         trans.gettext().tostring(),         color.gettext().tostring() }; public string path = environment.getexternalstoragedirectory().getabsolutepath() + "/listcars"; 

in oncreate method add :

   make = (edittext)findviewbyid(r.id.txtmake);     model = (edittext)findviewbyid(r.id.txtmodel);     year = (edittext)findviewbyid(r.id.txtyear);     price = (edittext)findviewbyid(r.id.txtprice);     trans = (edittext)findviewbyid(r.id.txttrans);     color = (edittext)findviewbyid(r.id.txtcolor);     addcar = (button)findviewbyid(r.id.btnadd);     uploadimg = (button)findviewbyid(r.id.btnupload);     cancel = (button)findviewbyid(r.id.btncancel);      file dir = new file(path);     dir.mkdirs(); 

the made 2 methods :

   public void btnadd(view view){     file file = new file(path + "/savedcars");     string savetext = string.valueof(toaddcar);     toast.maketext(getapplicationcontext(),"saved", toast.length_long).show();         save(file,savetext);  } public static void save(file file, string[] data) throws ioexception {     fileoutputstream fos = null;     try     {         fos = new fileoutputstream(file);     }     catch (filenotfoundexception e) {e.printstacktrace();}     try     {         try         {             (int = 0; i<data.length; i++)             {                 fos.write(data[i].getbytes());                 if (i < data.length-1)                 {                     fos.write("\n".getbytes());                 }             }         }         catch (ioexception e) {e.printstacktrace();}     }         {         fos.close();     } } 

the problem don't know how can implement edittexts in file want save in , upload image , save file well. if can me appreaciate :)

thanks

i'll give theoretical brief on read & how things go.

in activity add tablayout , viewpager show tabs & it's contents. each screen display on tab click, create fragment.

use fragmentstatepageradapter manage loading & displaying of fragments.

this simple & tutorial on it.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -