I create an application of user registration. When user registers in the application, I want to save the user data on an HTTP server. How can I do this?
1 Answer
You can store data on a remote server using networking. One example in this article.
Example of how to store a file on a remote server (from the article above):
File f = new File("/path/fileToUpload.txt");
HttpRequest request = new HttpRequest("http://host/some_path");
Part[] parts = {
new StringPart("param_name", "value"),
new FilePart(f.getName(), f)
};
filePost.setEntity( new MultipartRequestEntity(parts, filePost.getParams()) );
HttpClient client = new HttpClient();
int status = client.executeMethod(filePost);
4 Comments
Paresh Mayani
this answer is really helpful...But what about sending data to SQLite database by HTTP?
Deepak
I did not try it. Hopefully it will work. Whether I have to store all the record to a File before sending it to the HTTP Server???
Benny Skogberg
@Paresh Mayani: There are already paid apps for storing on SQL-servers: androlib.com/android.application.com-quickdb-Fp.aspx. To build your own solution take a look at java.net: developer.android.com/reference/java/net/package-summary.html and android.net developer.android.com/reference/android/net/…. In my view, a remote SQLite is a bit odd. SQLite is a tiny DBMS having its primary use in limited environments. Remote storage is better (and faster) with MySQL- or MS SQL-server. Hope this helps! Sincerely,
Benny Skogberg
@Deepak: Not necessary. Your app should be used by more than one user, and each user than should transfer her/his own file to your remote server. Another way is to use a database (see comment above). Good Luck!