3

I have an android application in my mobile, in which I fill some data and then I want to append this data to the database. So I am planning to add a button(sms button) in my application, on pressing this button, the data has to update to the server database or it can just dump the data in the server. So I want to know can we send sms to a server? and if yes, how?
Note: I have a server with a static IP address.

3 Answers 3

2

try posting the data to server.

public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php"); try { // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("id", "msgId")); nameValuePairs.add(new BasicNameValuePair("stringdata", "Msg u want send")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); Log.v("myapp", "response " + response.getEntity()); String responseBody = EntityUtils.toString(response.getEntity()); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } } 

You can refer to Android HttpPost: how to get the result http://www.anddev.org/doing_http_post_with_android-t492.html

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

1 Comment

Could you please elaborate. I am new to android. I want to send it as a sms from my mobile.
1

You could try with HTTP-request and have a serverside script (php/java/...) collect the data and put it in the database. Encoding can be done with JSON (or one of its variants). The fact that you have a static IP makes this pretty easy.

If you have a dataconnection (and since you're using a smartphone, you probably have), you're better of using your internet connection

Comments

0

When you add a GPRS Modem to your server and insert an active SIM card in it, you can send SMSes to that number and then you still need some service that will read your SMS and convert/dumps the data to the server itself.

2 Comments

Thanks TimVK for the reply. Is there any service or method available to read sms from modem?
I think I tried once the software of ActiveExperts but that is already some years ago.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.