don't want to set value of string static
<p>I want to set the string value initially when application starts without making it static &amp; further more i want to set the value of string variable by the user input. How can i set the values firstly &amp; afterward get it by the user???</p>

<p>Kindly help me</p>

<p>my code is:</p>

<pre><code> TextView GPS_Long_txtbx;
     TextView GPS_Lat_txtbx;
     static TextView last_update_time_txtbx;
     TextView onfig_txtbx;
     static String pswd_auth= "13579";
     static String interval = "120";
     String Saveinterval = "interval.txt";
     String FILENAME3 = "savetime";
     String Savetime = "savetime.txt";
</code></pre>

<p>my application works fine when i make "interval" &amp; "pswd_auth" static but if i remove static keyword from here it generate error "Cannot make a static reference to the non-static field ETrackActivity.pswd_auth" &amp; suggest "Change modifier pswd.auth to static"</p>

<p>Please suggest a solution. I'll be very thankful to you.</p>

<p>another activity code where i use static values:</p>

<p>public class Configuration extends Activity implements OnItemSelectedListener {</p>

<pre><code>public static final Message evt = null;
private static final Object minutes = null;
private static final Object seconds = null;



Spinner GPRS;
String [] name_of_GPRS_available;
int [] apn_id;
EditText GPS_Long_txtbx,GPS_Lat_txtbx,pswd_auth_txtbx,IMEI_txtbx,network_code_txtbx,server_host_txtbx,cell_tower_id_txtbx,interval_txtbx;
GsmCellLocation location;
String FILENAME = "saved";
String Savespinner = "spinner.txt";
String FILENAME1 = "save";
String Saveinterval = "interval.txt";
String FILENAME2 = "saveserver";
String Saveserver = "server.txt";
boolean IsRestored = false;



public void SaveRecord2(String data) {
    try {
        File dir = getFilesDir();
        File file = new File(dir, Saveserver);
        if (file.exists())
            file.delete();
        FileOutputStream fos = openFileOutput(Saveserver,
                Context.MODE_PRIVATE);
        fos.write(data.getBytes());
        fos.close();
    } catch (Exception ex) {
        ex.getMessage();
    }
}


public void RestoreRecord2() {
try {

File dir = getFilesDir();
File file = new File(dir, Saveserver);
if (!file.exists()) {
    return;
}


FileInputStream fileIS = new FileInputStream(file);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
String readString = new String();
String data = " ";

// just reading each line and pass it on the debugger

while ((readString = buf.readLine()) != null) {
    data += readString;
}

server_host_txtbx = (EditText) findViewById(R.id.server_host_txt);
server_host_txtbx.setText(ETrackActivity.server_host);

}

catch (Exception ex) {
ex.getMessage();
}
return;
}


public void SaveRecord(String data) {
    try {
        File dir = getFilesDir();
        File file = new File(dir, Savespinner);
        if (file.exists())
            file.delete();
        FileOutputStream fos = openFileOutput(Savespinner,
                Context.MODE_PRIVATE);
        fos.write(data.getBytes());
        fos.close();
    } catch (Exception ex) {
        ex.getMessage();
    }
}

public void RestoreRecord() {
    try {


        File dir = getFilesDir();
        File file = new File(dir, Savespinner);
        if (!file.exists()) {                           
            return;
        }

        FileInputStream fileIS = new FileInputStream(file);
        BufferedReader buf = new BufferedReader(new InputStreamReader(
                fileIS));
        String readString = new String();
        String data = "";
        // just reading each line and pass it on the debugger

        while ((readString = buf.readLine()) != null) {
            data += readString;
        }


        GPRS = (Spinner) findViewById(R.id.GPRS);
        GPRS.setSelection(Integer.parseInt(data));          

    } catch (Exception ex) {
        ex.getMessage();
    }
}



public void Savespinner(String Savespinner) {
    try {
        File dir = getFilesDir();
        File file = new File(dir, Savespinner);
        if (file.exists())
            file.delete();
        FileOutputStream fos = openFileOutput(Savespinner,
                Context.MODE_PRIVATE);
        fos.write(Savespinner.getBytes());
        fos.close();
    } catch (Exception ex) {
        ex.getMessage();
    }
}



public void SaveRecord0(String data) {
    try {
        File dir = getFilesDir();
        File file = new File(dir, Saveinterval);
        if (file.exists())
            file.delete();
        FileOutputStream fos = openFileOutput(Saveinterval,
                Context.MODE_PRIVATE);
        fos.write(data.getBytes());
        fos.close();
    } catch (Exception ex) {
        ex.getMessage();
    }
}


public void RestoreRecord0() {
    try {


        File dir = getFilesDir();
        File file = new File(dir, Saveinterval);
        if (!file.exists())
        {                           
            return;
        }

        FileInputStream fileIS = new FileInputStream(file);
        BufferedReader buf = new BufferedReader(new InputStreamReader(
                fileIS));
        String readString = new String();
        String data = "";
        // just reading each line and pass it on the debugger

        while ((readString = buf.readLine()) != null) {
            data += readString;
        }

        interval_txtbx = (EditText) findViewById(R.id.interval_txt);
        interval_txtbx.setSelection(get(timer));
        interval_txtbx.setText(data);

    } 

    catch (Exception ex) {
        ex.getMessage();
    }
}


private int get(Timer timer) {

    return 0;

}


public void Saveinterval(String Saveinterval) {
    try {
        File dir = getFilesDir();
        File file = new File(dir, Saveinterval);
        if (file.exists())
            file.delete();
        FileOutputStream fos = openFileOutput(Saveinterval,
                Context.MODE_PRIVATE);
        fos.write(Saveinterval.getBytes());
        fos.close();
    } catch (Exception ex) {
        ex.getMessage();
    }
}

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.configuration); 

    EnumerateAPNs();

   /* this is a android enviroment in which you can develop an android application in which you 
    * share all your basic necessities of thrkife bghhr4y2ghrrr*/

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    GPRS = (Spinner)findViewById(R.id.GPRS);
    ArrayAdapter&lt;?&gt; spinner_array = new ArrayAdapter&lt;Object&gt;(this,android.R.layout.simple_dropdown_item_1line,name_of_GPRS_available);
    spinner_array.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());     
    Editor prefsEditor = prefs.edit();     
    prefsEditor.putString("Object", name_of_GPRS_available.toString());     
    prefsEditor.commit(); 
    GPRS.setAdapter(spinner_array);
    //GPRS.setOnItemSelectedListener(MyOnItemSelectedListener());
    GPRS.setOnItemSelectedListener(new MyOnItemSelectedListener());

    RestoreRecord();

    MyLocation loc = new MyLocation(this.getApplicationContext());
    GPS_Long_txtbx = (EditText) findViewById(R.id.GPS_Long_txt);
    GPS_Long_txtbx.setText(String.valueOf(loc.gps_lon));
    GPS_Lat_txtbx = (EditText) findViewById(R.id.GPS_Lat_txt);
    GPS_Lat_txtbx.setText(String.valueOf(loc.gps_lat));


    IMEI_txtbx = (EditText)findViewById(R.id.IMEI_txt);
    IMEI_txtbx.setText(tm.getDeviceId());

    network_code_txtbx = (EditText)findViewById(R.id.network_code_txt);
    network_code_txtbx.setText(tm.getNetworkOperator());

    RestoreRecord2();

    server_host_txtbx = (EditText) findViewById(R.id.server_host_txt);
    server_host_txtbx.setText(ETrackActivity.server_host);

    pswd_auth_txtbx = (EditText)findViewById(R.id.pswd_auth);
    pswd_auth_txtbx.setText(ETrackActivity.pswd_auth);



    interval_txtbx = (EditText)findViewById(R.id.interval_txt);
    interval_txtbx.setText(String.valueOf(ETrackActivity.interval));

    RestoreRecord0();

    location = (GsmCellLocation) tm.getCellLocation();
    cell_tower_id_txtbx = (EditText) findViewById (R.id.cell_tower_id_txt);
    cell_tower_id_txtbx.setText(String.valueOf(location.getCid()));


    interval_txtbx.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Onclick_click1(interval_txtbx);

        }
    });


server_host_txtbx.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v){
        Onclick_click2(server_host_txtbx);
    }
});



pswd_auth_txtbx.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v ){
        Onclick_click(pswd_auth_txtbx);
    }


        });
</code></pre>

<p>}</p>

<pre><code>private OnItemSelectedListener listener;
public Intent BROADCAST_ACTION;
public long startTime;
public java.util.Timer timer;
protected Object mUpdateTimeTask;
protected Handler mHandler;
static TelephonyManager tm;



public void Onclick_click1(final EditText txtbx)
{
    final EditText txtbox = (EditText) txtbx;

    if(txtbx.getId()==R.id.interval_txt)
    {

        {

            final AlertDialog authentication = new AlertDialog.Builder(Configuration.this).create();
            authentication.setTitle("Authentication");
            final EditText pswd_auth = new EditText(Configuration.this);
            authentication.setView(pswd_auth);

            authentication.setButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(final DialogInterface dialog, int whichButton) {    


                if(ETrackActivity.pswd_auth.equals(pswd_auth.getText().toString()))
                {
                    txtbx.setFocusableInTouchMode(true);
                    txtbx.setFocusable(true);
                    txtbx.setClickable(false);
                    txtbx.setFocusable(true);
                    txtbx.setText("");

                       if(txtbx.isClickable()==false)
                       {
                           txtbx.setOnClickListener(new OnClickListener(){
                                public void onClick(View arg0) {    
                                            txtbx.setInputType(txtbx.getInputType());

                                }
                           });
                       }

                       String value = txtbx.getText().toString();

               SaveRecord(value);    


                }
                else
                {

                                Toast.makeText(Configuration.this, "Worng Password", Toast.LENGTH_SHORT).show();
                            txtbx.setInputType(InputType.TYPE_NULL);
                            txtbx.setKeyListener(null);
                                                        }
                    }               
                });

            authentication.show();


        }
    }

}


public void Onclick_click2(final EditText txtbx)
{
    final EditText txtbox = (EditText) txtbx;

    if(txtbx.getId()==R.id.server_host_txt)
    {

        final AlertDialog authentication = new AlertDialog.Builder(Configuration.this).create();
        authentication.setTitle("Authentication");
        final EditText pswd_auth = new EditText(Configuration.this);
        authentication.setView(pswd_auth);

        authentication.setButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, int whichButton) {
            if(ETrackActivity.pswd_auth.equals(pswd_auth.getText().toString()))
            {
                txtbx.setFocusableInTouchMode(true);
                txtbx.setFocusable(true);
                txtbx.setClickable(false);
                txtbx.setFocusable(true);
                txtbx.setText("");

                   if(txtbx.isClickable()==false)
                   {
                       txtbx.setOnClickListener(new OnClickListener(){
                            public void onClick(View arg0) {    
                                        txtbx.setInputType(txtbx.getInputType());

                            }
                       });
                   }

                   String value = txtbx.getText().toString();

                   SaveRecord(value);


            }
            else            
                    {
                        Toast.makeText(Configuration.this, "Worng Password", Toast.LENGTH_SHORT).show();
                        txtbx.setInputType(InputType.TYPE_NULL);
                        txtbx.setKeyListener(null);

                    }
                }               
            });

        authentication.show();


    }
}

    public void Onclick_click(final EditText txtbx)
    {

        final EditText txtbox = (EditText) txtbx; 


       if(txtbx.getId()==R.id.pswd_auth)
       {


           final AlertDialog Change_Password = new AlertDialog.Builder(this)
            .setPositiveButton("OK",new Dialog.OnClickListener() {
               public void onClick(DialogInterface d, int which) {

               }
           })
           .setNegativeButton("Cancel", new Dialog.OnClickListener(){
               public void onClick(DialogInterface d , int which){

               }
           })
            .create();
            Change_Password.setTitle("Password Change");

            LinearLayout option_list= new LinearLayout(this);
            option_list.setOrientation(1);

            final EditText old_pswd_auth = new EditText(Configuration.this);
            final EditText new_pswd_auth= new EditText(Configuration.this);

            TextView o_p =new TextView(Configuration.this);
            TextView n_p= new TextView(Configuration.this);

            o_p.setText("Old Password");
            n_p.setText("New Password");

            option_list.addView(o_p);
            option_list.addView(old_pswd_auth);
            option_list.addView(n_p);
            option_list.addView(new_pswd_auth);
            Change_Password.setView(option_list);

            Change_Password.setButton("Ok", new DialogInterface.OnClickListener(){
                public void onClick(DialogInterface dialog, int whichButton)
                {
                    if(ETrackActivity.pswd_auth.equals(old_pswd_auth.getText().toString()))
                    {
                        Toast.makeText(Configuration.this, "Password Change Successfully", Toast.LENGTH_SHORT).show();
                        ETrackActivity.pswd_auth=new_pswd_auth.getText().toString();
                        txtbx.setText(new_pswd_auth.getText().toString());
                        txtbx.setInputType(txtbox.getInputType());
                    }
                    else
                        Toast.makeText(Configuration.this, "Worng Password, failed to change password", Toast.LENGTH_SHORT).show();

                }
            });
           Change_Password.setButton2("Cancel", new DialogInterface.OnClickListener(){
               public void onClick(DialogInterface dialog, int whichButton)
                {
                    Change_Password.cancel();
                }
            });
           Change_Password.show();

           }

       else
       {

        final AlertDialog authentication = new AlertDialog.Builder(Configuration.this).create();
        authentication.setTitle("Authentication");
        final EditText pswd_auth = new EditText(Configuration.this);
        authentication.setView(pswd_auth);

        authentication.setButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, int whichButton) {


                    if(ETrackActivity.pswd_auth.equals(pswd_auth.getText().toString()))
                    {
                        txtbx.setFocusableInTouchMode(true);
                        txtbx.setFocusable(true);
                        txtbx.setClickable(false);
                        txtbx.setFocusable(true);
                        txtbx.setText("");

                           if(txtbx.isClickable()==false)
                           {
                               txtbx.setOnClickListener(new OnClickListener(){
                                    public void onClick(View arg0) {    
                                                txtbx.setInputType(txtbx.getInputType());

                                    }
                               });
                           }

                    }
                    else
                    {
                        Toast.makeText(Configuration.this, "Worng Password", Toast.LENGTH_SHORT).show();
                        txtbx.setInputType(InputType.TYPE_NULL);
                        txtbx.setKeyListener(null);
                        Configuration.this.Onclick_click(pswd_auth_txtbx);
                    }
                }               
            });

        authentication.show();
       }
    }

       public void onStop()
    {
        super.onStop();

        if(!server_host_txtbx.getText().toString().equals(""))
            ETrackActivity.server_host = server_host_txtbx.getText().toString();

        if(!interval_txtbx.getText().toString().equals(""))
            ETrackActivity.interval = interval_txtbx.getText().toString();

        if(!pswd_auth_txtbx.getText().toString().equals(""))
            ETrackActivity.pswd_auth = pswd_auth_txtbx.getText().toString();
    }
</code></pre>
