shift between the activites
<p>I am making android app in which i am facing problem . The overview of the problem is like this 
Three Activities A B C </p>

<p>A is the main activity 
B is the sharepref activty 
C is the list activty which is fetching the data from the server using the id store in B(share perf)</p>

<p>when i install the app and set the id in B and click on save button it goes to A 
but for the rest of the time whenever i click on save setting in B it goes to c     </p>

<p>Please help me about that whenever i click on savesetting in activity B it should always goes to activity A</p>

<p>Let me know if the code needs to be uploaded (all the activities are working f9)</p>

<p>Here is the main class where i want to come back(A according to question) </p>

<pre><code>public class ControlMenu extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.settings:     
                Intent intent = new Intent(this, ShowSettings.class);
                  startActivity(intent);
            break;
            case R.id.services:     
                Intent intent2 = new Intent(this, Test.class);
                startActivity(intent2);
              break;
            case R.id.Quit: 

                finish();

                break;
            default:    
            break;
        }
        return true;
    }
}
</code></pre>

<p>Here is the List activty which is callinf the list or ( C according to the question)</p>

<pre><code>public class Test extends ListActivity  {
      Prefs myprefs = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
        calling the list
    }



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.settings:     
                Intent intent = new Intent(this, ShowSettings.class);
                  startActivity(intent);
            break;
            case R.id.services:     
                Intent intent2 = new Intent(this, Test.class);
                startActivity(intent2);
              break;
            case R.id.Quit: 

                finish();



                break;
            default:    
            break;
        }
        return true;
    }
}
</code></pre>

<p>Here is the sharedpref from where i want to go to A and it is divied into two classes </p>

<pre><code>public class Prefs {

    private SharedPreferences _prefs = null;
    private Editor _editor = null;
    private String _useremailaddress = "Unknown";
    private String _serverurl = "http://chinar.gofreeserve.com/db.php";

    public Prefs(Context context) {
        this._prefs = context.getSharedPreferences("PREFS_PRIVATE", Context.MODE_PRIVATE);
        this._editor = this._prefs.edit();
    }

    public String getValue(String key, String defaultvalue) {
        if (this._prefs == null) {
            return "Unknown";
        }

        return this._prefs.getString(key, defaultvalue);
    }

    public void setValue(String key, String value) {
        if (this._editor == null) {
            return;
        }

        this._editor.putString(key, value);

    }

    public String getEmail() {
        if (this._prefs == null) {
            return "Unknown";
        }

        this._useremailaddress = this._prefs.getString("emailaddress", "noidea");
        return this._useremailaddress;
    }

    public String getServer() {
        if (this._prefs == null) {
            return "http://chinar.gofreeserve.com";
        }

        this._serverurl = this._prefs.getString("serverurl", "http://chinar.gofreeserve.com/");
        return this._serverurl;
    }

    public void setEmail(String newemail) {
        if (this._editor == null) {
            return;
        }

        this._editor.putString("emailaddress", newemail);
    }

    public void setServer(String serverurl) {
        if (this._editor == null) {
            return;
        }
        this._editor.putString("serverurl", serverurl);
    }

    public void save() {
        if (this._editor == null) {
            return;
        }
        this._editor.commit();
    }
}
</code></pre>

<p>and the last class which is used by pref </p>

<pre><code>public class ShowSettings extends ControlMenu {

    Prefs myprefs = null;

    final String tag = "CH12:ShowSettings";

    AlertDialog.Builder adb;// = new AlertDialog.Builder(this);

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        setContentView(R.layout.showsettings);

        this.myprefs = new Prefs(getApplicationContext());

        // load screen
        PopulateScreen();

        this.adb = new AlertDialog.Builder(this);

        final Button savebutton = (Button) findViewById(R.id.settingssave);

        // create anonymous click listener to handle the "save"
        savebutton.setOnClickListener(new Button.OnClickListener() {

            public void onClick(View v) {
                try {

                    // get the string and do something with it.

                    final EditText email = (EditText) findViewById(R.id.emailaddress);
                    if (email.getText().length() == 0) {

                        AlertDialog ad = ShowSettings.this.adb.create();
                        ad.setMessage("Please Enter Your Email Address");
                        ad.show();
                        return;
                    }

                    final EditText serverurl = (EditText) findViewById(R.id.serverurl);
                    if (serverurl.getText().length() == 0) {
                        AlertDialog ad = ShowSettings.this.adb.create();
                        ad.setMessage("Please Enter The Server URL");
                        ad.show();
                        return;
                    }

                    // save off values
                    ShowSettings.this.myprefs.setEmail(email.getText().toString());
                    ShowSettings.this.myprefs.setServer(serverurl.getText().toString());
                    ShowSettings.this.myprefs.save();

                    // we're done!
                    finish();
                } catch (Exception e) {
                    Log.i(ShowSettings.this.tag, "Failed to Save Settings [" + e.getMessage() + "]");
                }
            }
        });
    }

    private void PopulateScreen() {
        try {
            final EditText emailfield = (EditText) findViewById(R.id.emailaddress);
            final EditText serverurlfield = (EditText) findViewById(R.id.serverurl);

            emailfield.setText(this.myprefs.getEmail());
            serverurlfield.setText(this.myprefs.getServer());
        } catch (Exception e) {

        }
    }
}
</code></pre>
