Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:13:11+00:00 2026-05-25T13:13:11+00:00

I am working on android. i am sending username and password using HttpPost and

  • 0

I am working on android. i am sending username and password using HttpPost and getting userid.

This is my code for my operation:

HttpClient hc = new DefaultHttpClient();

HttpPost post = new HttpPost("http://192.168.1.214/sample/dologin.php id="+strUID+ "&password="+strPass);

HttpResponse rp = hc.execute(post);

if (rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
    String userID = EntityUtils.toString(rp.getEntity());
    Log.v("Login response", "" + userID);
}

This is my output in DDMS

Login response(686): ([{"id":"5"}]);

But I need 5 as a result. So I can use this result in my next operations. Please tell me what should I do to extract 5 from the string ([{“id”:”5″}]);

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:13:11+00:00Added an answer on May 25, 2026 at 1:13 pm

    You can use JSON below is simple code..

    StringBuffer sb = new StringBuffer(userID);
    String s = sb.substring(sb.indexOf("["),sb.lastIndexOf("]")+1);
    JSONArray ja = new JSONArray(s);
    JSONObject jo = new JSONObject();
    jo = (ja.getJSONObject(0));
    String id = jo.getString("id");
    

    Now you can use id variable..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working android application my problem is i am using handlers this handler
I am new in this field. I am working on Android application development. I
I am working on sending Meeting Invites from my Android app. Here is the
I am working on an android app in which I am using some Native
This is one of those cases where I had the code working, tried to
Hi I am working Android application development using titanium studio.I have developed small application.my
I'm using ksoap2-Android on an Android project to upload a file. It's not working.
Why is it so hard to find an Android example of sending email using
I have written a code in android as as well as in php..while sending
I am using RequestFactory with appengine and android. It has been working great, however

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.