Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development > Developer 101

Developer 101 101 Tutorials



Reply
 
LinkBack Thread Tools
Old October 26th, 2011, 11:39 AM   #1 (permalink)
Junior Member
 
Join Date: Oct 2011
Posts: 21
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default KSoap web service response

Hi everyone,

I've connected to a .net web service with KSoap2 and can display the response as a string fine, however I need to take that information and store it locally in an xml file.

Is this possible?

I was looking at saving the response information in a variety of variables, placing those in a JTable and then saving that out.

Any help or suggestions would be greatly received.

Thanks

the phantom is offline  
Reply With Quote
Sponsors
Old November 18th, 2011, 04:22 AM   #2 (permalink)
Junior Member
 
Join Date: Oct 2011
Posts: 21
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As a follow up to this I managed to allocate out each value from the SOAP response into a number of STRING variables and then created another big STRING that contained all of the desired XML tags with the various variables appended inbetween so essentially it represents the XML content.

I saved this using the following code(FullDescription is the big string with everything in);
FileOutputStream fos = openFileOutput(
"testerfile.xml", Context.MODE_PRIVATE);

fos.write(
"".getBytes());

fos.write(
FullDescription.getBytes());

fos.close();

I can then view the contents of the file using the Toast method. However....even though I'm shown the content of the apparent file I can't actually find the file anywhere in my files that actually make up my app? If there's a file that exists and it shows me what's in it then surely I must be able to see the physical file?

Can anyone offer any input?
the phantom is offline  
Reply With Quote
Old November 19th, 2011, 03:37 PM   #3 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

Wrap the the FileOutputStream in an OutputStreamWriter. In general in Java, use Reader and Writer when dealing with text. Use InputStream and OutputStream only when dealing with binary data.

Code:
Writer wtr
  = new OutputStreamWriter(
       openFileOutput("testerfile.xml", Context.MODE_PRIVATE),
       "UTF-8"
    );
wtr.write("<?xml version='1.0' encoding='UTF-8'?>\n");
wtr.write(FullDescription);
wtr.close();

In regards to where the file goes, you should find the file at the following path:

/data/data/app package/files/testerfile.xml

where app package is the package specified in your AndroidManifest.xml.
jiminaus is offline  
Last edited by jiminaus; November 19th, 2011 at 03:56 PM.
Reply With Quote
Old November 23rd, 2011, 03:49 AM   #4 (permalink)
Junior Member
 
Join Date: Oct 2011
Posts: 21
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Excellent, many thanks for the info :-)
the phantom is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development > Developer 101 User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:10 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo