I was able to download 开发者_Python百科this form to my sdcard (from a given URL):
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.
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)
精彩评论