1

I was able to download this form to my sdcard (from a given URL): enter image description here

My app can access this form via the android web view. My question is, how to save it to a text file after a user filled data to the form? I want to save in the text file the data inputted by the user, for instance:

Address: User address here City: User City Province: User Province here Zip: 4342343 Phone: 4534534534 What is your biggest regret in your life? None. 

will be saved to the text file... I'm kinda new to java and android dev.

1 Answer 1

1

If you want to store the data locally, you should implement this form as a widget-based Activity rather than using a WebView.

If these values should be processed by a server, submit it like any other HTML form and let the server pick the values from the HTTP POST request.

EDIT

It is possible to attach a WebViewClient to the WebView, to allow methods in the WebView's Activity to be called from JavaScript. See sample code.

Your HTML file would need to contain JavaScript that runs when the "Submit" button is clicked, collects the contents of the form and then passes it to the WebViewClient.

(There might be an even easier way, see: Android Calling JavaScript functions in WebView)

Sign up to request clarification or add additional context in comments.

8 Comments

Thank you for your response Jen, yes I want to store it locally, hmm what do you mean by widget-based activity?
Instead of using HTML-based text fields, use a TextView for each field. Her's a tutorial: coenraets.org/blog/android-samples/androidtutorial. Have a look at Step 5, which shows how to create the Activity: code.google.com/p/androidtutorial/source/browse/trunk/…
But the text fields here is dynamic. They are downloaded from a URL (given by XML). Is there a way to convert those fields to android text views dynamically?
1. How often do the questions change? 2. If a server generates the questions, wouldn't it make more sense for the server to process the responses?
It's an interesting topic, and it does look like a very good reason to use WebView
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.