title: how can I retrieve user's login id from mysql using global variable in my android app?
body: <p>I am very new in android.In my app I want when a user login that user's id is carried all activity.Like a session management.That user id comes from mysql database.I want to carry login user id to all tab which shows in main activity.I tried global variable but its didn't work.please give me some solutions....</p>
  
  <p><strong>LoginActivity</strong></p>
  
  <pre><code>@Override
  public void onClick(View view) {
  
      // Get text from email and passord field
      String email = UsernameEt.getText().toString();
      String password = PasswordEt.getText().toString();
      String type = "login";
      BackgroundWorker backgroundWorker = new BackgroundWorker(this);
      backgroundWorker.execute(type, email, password);
      //finish();
      Intent intent = new Intent(UserLogin.this, MainActivity.class);
      startActivity(intent);
      finish();
  
  }
  </code></pre>
  
  <p><strong>BackgroundWorker class</strong></p>
  
  <pre><code>public class BackgroundWorker extends AsyncTask&lt;String,Void,String&gt; {
  
  Context context;
  AlertDialog alertDialog;
  
  
  BackgroundWorker (Context ctx){
  
      context = ctx;
  
  }
  
  @Override
  protected String doInBackground(String... params) {
  
      String type = params[0];
      String login_url = "http://www.mybusket.com/pmsapp/webs/get_all_emp.php";
      if (type.equals("login")){
  
          try {
              String email_id = params[1];
              String password = params[2];
              URL url = new URL(login_url);
              HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
              httpURLConnection.setRequestMethod("POST");
              httpURLConnection.setDoOutput(true);
              httpURLConnection.setDoInput(true);
              OutputStream outputStream = httpURLConnection.getOutputStream();
              BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
              String post_data = URLEncoder.encode("email_id", "UTF-8")+"="+URLEncoder.encode(email_id, "UTF-8")+"&amp;"
                      +URLEncoder.encode("password", "UTF-8")+"="+URLEncoder.encode(password, "UTF-8");
              bufferedWriter.write(post_data);
              bufferedWriter.flush();
              bufferedWriter.close();
              outputStream.close();
              InputStream inputStream = httpURLConnection.getInputStream();
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
              String result="";
              String line="";
              while ((line = bufferedReader.readLine())!= null){
                  result += line;
              }
              bufferedReader.close();
              inputStream.close();
              httpURLConnection.disconnect();
              return result;
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  
      return null;
  }
  </code></pre>
  
  <p>From this class Validate email address..How can I carry logged in user's id which save in mysql database, to all activity.</p>