[android-developers] Re: Saving form data to XML
To create new xml file on SD card I am using following code String strFileName = Environment.getExternalStorageDirectory()+/ + temp.xml; try{ if(!lXmlfile.exists()) { lXmlfile.createNewFile(); } }catch(IOException e){ Log.e(IOException, e.toString()); return null; } Above code giving me IO exception Permission denied. Although I have added permission in AndroidManifest.xml like: uses-permission android:name=android.permission.WRITE_EXTERNAL_STORAGE/ still , can not create file. where am I going wrong? how can I test this on emulator (create file on which path?) .Pls help its urgent. One more question: Is user defined content provider is the best way to complete this requirement(saving and retrieving form data that also contains image). Pls share. Regards On Sep 26, 7:41 am, gjs garyjamessi...@gmail.com wrote: Hi, Seehttp://developer.android.com/reference/android/content/Context.html#g...() andhttp://developer.android.com/guide/topics/data/data-storage.html Regards On Sep 23, 7:28 pm, ksmobilejava ksmobilej...@gmail.com wrote: Hello , developing application withformhaving multiple fields, at the end user need to submit the information. On this event, all thedataneed to be stored inXMLfile. thusXMLwrite is required. plus when user asks for particular id then thedatafilled by that id is also to be displayed thusXMLread is required.(search operation) Following is the code I tried for generating samplexml. /// // FileOutputStream fileos = null; try{ fileos=openFileOutput(newxml.xml,Context.MODE_PRIVATE); Log.v(info,fileoutput open); // fileos = new FileOutputStream(newxmlfile); }catch(FileNotFoundException e){ Log.e(FileNotFoundException, can't create FileOutputStream); } // create a XmlSerializer in order to writexmldata XmlSerializer serializer =Xml.newSerializer(); try { //we set the FileOutputStream as output for the serializer, using UTF-8 encoding serializer.setOutput(fileos, UTF-8); //Write ?xmldeclaration with encoding (if encoding not null) and standalone flag (if standalone not null) serializer.startDocument(null, Boolean.valueOf(true)); //set indentation option //serializer.setFeature(http://xmlpull.org/v1/doc/ features.html#indent-output, true); //start a tag called root serializer.startTag(null, root); //i indent code just to have a view similar toxml-tree serializer.startTag(null, child1); serializer.endTag(null, child1); serializer.startTag(null, child2); //set an attribute called attribute with a value for child2 serializer.attribute(null, attribute, value); serializer.endTag(null, child2); serializer.startTag(null, child3); //write some text inside child3 serializer.text(some text inside child3); serializer.endTag(null, child3); serializer.endTag(null, root
[android-developers] Saving form data to XML
Hello , developing application with form having multiple fields, at the end user need to submit the information. On this event, all the data need to be stored in XML file. thus XML write is required. plus when user asks for particular id then the data filled by that id is also to be displayed thus XML read is required.(search operation) Following is the code I tried for generating sample xml. / FileOutputStream fileos = null; try{ fileos=openFileOutput(newxml.xml,Context.MODE_PRIVATE); Log.v(info,fileoutput open); // fileos = new FileOutputStream(newxmlfile); }catch(FileNotFoundException e){ Log.e(FileNotFoundException, can't create FileOutputStream); } // create a XmlSerializer in order to write xml data XmlSerializer serializer = Xml.newSerializer(); try { //we set the FileOutputStream as output for the serializer, using UTF-8 encoding serializer.setOutput(fileos, UTF-8); //Write ?xml declaration with encoding (if encoding not null) and standalone flag (if standalone not null) serializer.startDocument(null, Boolean.valueOf(true)); //set indentation option //serializer.setFeature(http://xmlpull.org/v1/doc/ features.html#indent-output, true); //start a tag called root serializer.startTag(null, root); //i indent code just to have a view similar to xml-tree serializer.startTag(null, child1); serializer.endTag(null, child1); serializer.startTag(null, child2); //set an attribute called attribute with a value for child2 serializer.attribute(null, attribute, value); serializer.endTag(null, child2); serializer.startTag(null, child3); //write some text inside child3 serializer.text(some text inside child3); serializer.endTag(null, child3); serializer.endTag(null, root); serializer.endDocument(); //write xml data into the FileOutputStream serializer.flush(); //finally we close the file stream fileos.close(); //TextView tv = (TextView)this.findViewById(R.id.result); //tv.setText(file has been created on SD card); Log.v(info,file has been created on SD card); return true; } catch (Exception e) { Log.e(Exception,error occurred while creating xml file); return false; } // executed this with actual device but, no new xml file is created. where to store this programatically created xml file? On emulator if I want to test this application, where the xml file will get stored? Pls guide me whats going wrong? Thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: multi page form
Thank you all, for help. I used view flipper and it worked as expected. Thanks Again. But still not clear with how to submit that form information and store it in XML file. Pls share. Thanks. On Sep 8, 2:12 am, rich friedel rich.frie...@gmail.com wrote: Like Mark Murphy said... use ViewFlipper to create the illusion of 'pages'http://developer.android.com/reference/android/widget/ViewFlipper.htmlthen store your data however you choose to do so...http://developer.android.com/guide/topics/data/data-storage.html -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] multi page form
Hello , I am new to android paltform. How to navigate through multi page form application? how to handle next and back button click event? My point of confusion is that, form filling is single activity , then how to display multiple pages of the form and how to navigate back and forth from pages in that activity? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: multi page form
Thanks all for help. The intended from has multiple fields (around 25-30 fields) so it can not be fitted in single screen. As all agrees , user doesn't like to scroll , I want to divide fields into multiple pages (~5 fields per page) and navigate through them from user friendly perspective. I read about Intents , but Intents make call to other activity from currently running activity. Conceptually form filling is single activity only it need to be divided into pages, so here , is it appropriate to use intents ? Further , the information entered in all pages need to be stored (as a record , may be in xml file) at the end of form filling. what is proper way to approach this requirement, Pls share. Thanks in advance. On Sep 6, 9:24 pm, Logesh rajendren loges...@gmail.com wrote: my advice is to shrink your UI so that it fits into a single page. because Users dont like to use scrolls. Design your form in such a way if its feasible . On Tue, Sep 6, 2011 at 6:03 AM, ksmobilejava ksmobilej...@gmail.com wrote: Hello , I am new to android paltform. How to navigate through multi page form application? how to handle next and back button click event? My point of confusion is that, form filling is single activity , then how to display multiple pages of the form and how to navigate back and forth from pages in that activity? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en