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 8922451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:50:15+00:00 2026-06-15T06:50:15+00:00

Hi guys there is an activity on my current android app that has a

  • 0

Hi guys there is an activity on my current android app that has a webview in it. I was wondering how I could take and store a variable from the php on that website (yes I control the website, and have full editing capabilities) into a variable on my android app.

  • 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-06-15T06:50:17+00:00Added an answer on June 15, 2026 at 6:50 am

    I would explain the things need to be done in general. First, at your android app side, there should be code something like this.

    1)At your android side

    String url = "www.yoururl.com/yourphpfile.php";
    List<NameValuePair> parmeters = new ArrayList<NameValuePair>();
                parameters.add(new BasicNameValuePair("category",category));
                parameters.add(new BasicNameValuePair("subcategory",subcategory));// These are the namevalue pairs which you may want to send to your php file. Below is the method post used to send these parameters
    
      DefaultHttpClient httpClient = new DefaultHttpClient();
    
      HttpPost httpPost = new HttpPost(url); // You can use get method too here if you use get at the php scripting side to receive any values.
    
      httpPost.setEntity(new UrlEncodedFormEntity(parameters));
    
      HttpResponse httpResponse = httpClient.execute(httpPost);
    
      HttpEntity httpEntity = httpResponse.getEntity();
    
      is = httpEntity.getContent();
    
       BufferedReader reader = new BufferedReader(new InputStreamReader(
                        is, "iso-8859-1"), 8); // From here you can extract the data that you get from your php file..
    
            StringBuilder builder = new StringBuilder();
    
            String line = null;
    
            while ((line = reader.readLine()) != null) {
                builder.append(line + "\n");
            }
    
            is.close();
            json = sb.toString(); // Here you are converting again the string into json object. So that you can get values with the help of keys that you send from the php side.
    
            String message = json.getString("message");
             int success = json.getInt("success"); // In this way you again convert json object into your original data.
    

    2) At your php side

    $response = array();
    
    // check for post fields
    if (isset($_POST['category']) && isset($_POST['subcategory'])) {
    
        $category = $_POST['category'];
        $subcategory = $_POST['subcategory'];
    
    
        // include db connect class
        require_once __DIR__ . '/db_connect.php';
    
        // connecting to db
        $db = new DB_CONNECT();
    
        // mysql inserting a new row
        $result = mysql_query("INSERT INTO categorytable(category, subcategory) VALUES('$category', '$subcategory')");
    
        // check if row inserted or not
        if ($result) {
            // successfully inserted into database
            $response["success"] = 1;
            $response["message"] = "Data inserted into database.";
    
            // echoing JSON response
            echo json_encode($response);// Here you are echoing json response. So in the inputstream you would get the json data. You need to extract it over there and can display according to your requirement.
    } 
    

    As you said you are fairly proficient in php, you might have found that the above things in php made as simple as possible and It’s not secured. So, you can follow some pdo or some other secured ways to code at php side. Make sure you surround the code at your android side in asynctask in order to run in separate thread wherever you need. Hope this helps.

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

Sidebar

Related Questions

Ok guys, could you tell me is there a certain bug in current code:
Hope you guys can help, I have a activity that has tabs, each tab
I have an app, that has an Activity that uses a ScrollView . I
guys: There is two buttons in my viewController of test app, the right one
Guys I have an activity which has a home button, when the button is
hey there guys and girls i have this code that saves json as a
I'm designing a music player app for Android that will feature pop-up controls. I'm
I am going to implement an application that is gathering data from Android device.
hey there guys and girls i have this code that should download a json
guys! Is there any way to set required .Net Framework in a more universal

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.