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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:54:03+00:00 2026-06-19T03:54:03+00:00

Hi i have developed an app which has a text box and a search

  • 0

Hi i have developed an app which has a text box and a search button when i enter a number in the text box and click on the search button it needs to pass the value entered to the next activity where it uses that value to get the value from a database.

I am using the following code to pass the value.

search_button.setClickable(true);
      search_button.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub
        String outlet_no = outlet_id.getText().toString();
        System.out.println(outlet_no);
        if(!outlet_no.isEmpty()){
        @SuppressWarnings("deprecation")
        SharedPreferences myPrefs = getApplicationContext().getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
        SharedPreferences.Editor prefsEditor = myPrefs.edit();

        prefsEditor.putString("outlet_id", outlet_no);
        prefsEditor.commit();

        Intent myIntent = new Intent(HomeActivity.this, StoreActivity.class);       
        startActivity(myIntent);
        HomeActivity.this.startActivity(myIntent);
        }
        else{
          Toast.makeText(getApplicationContext(), "Please enter an outlet id", Toast.LENGTH_SHORT);
        }  
      }
    });

My problem is that it doesnot pass the value. Can any one help me with this and also can any1 explain me the above code as i didnot write it and i am finding it difficult to understand it.

StoreActivity side

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.store);      
        myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);             
        mOutletID = myPrefs.getString("outlet_id", "0");
        mOutletDetails = myPrefs.getString("outlet_details","{}");
        Log.v("outlet_details",myPrefs.getString("outlet_details","{}"));
        if(mOutletDetails != "{}"){
            setOutletData(mOutletDetails);
        }
        else{
            executeAjaxRequest();
        }
    }    
  • 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-19T03:54:04+00:00Added an answer on June 19, 2026 at 3:54 am

    Mistakes you made:

    1) Why are you trying to start activity twice?

    startActivity(myIntent);   // this is OK
    HomeActivity.this.startActivity(myIntent);
    

    2) To pass entered text from one activity to another, you can use putExtra() method of Intent, for example:

    myIntent.putExtra("SearchText", outlet_no);
    

    So your complete code would be:

     Intent myIntent = new Intent(HomeActivity.this, StoreActivity.class);   
     myIntent.putExtra("SearchText", outlet_no);    
     startActivity(myIntent);
    

    3) To receive value which you have passed from first activity:

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    String outlet_no= bundle.getString("SearchText");
    

    4) SharedPreferences:

    FYI, SharedPreference is used to save small amount of data which can be reference and used later across application.

    You should refer below links:

    1. SharedPreferences
    2. Intent
    3. Intent and Intent Filters
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have developed an app which executes sql jobs. When I click on execute
I have musical app developed for OS X, which has following features, Play multiple
I have a Win32 app developed in C++ Builder XE, which has worked great
I have current a developed app which I am going to submit in just
I have enrolled in the iOS developer's program. I've developed an app which I
I have developed a system app for my rom which includes some native libraries.
I have developed a blackberry app, in which I am using Persistent Storage to
I have developed an app that in testing has worked fine but when it
We have developed a messaging application in j2me which adds text message, gets pictures
Hi i have developed an app which i am trying to run directly on

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.