I am not very familiar with java coding but I wanted to make my own app.

I want to use `SharedPreferences` to store some values across different activities/classes as is shown in multiple tutorials (and also questions on this site) but when I try to read them in another activity which is in another class I get random numbers like 2131361821.

The user has to fill out a `textview` field with id `direction_1000` so I get a wind direction at 1000ft via the class GetWind.

If I store this value as an `int` in `SharedPreference` all works fine but If I want to pass this value to the class `InputNavData` and display it over there via the `int` `PHI` and `String` `phi` I get this strange value. 

Can someone help me to solve this? Sorry in advance for the messy code and question but as I said it's all very new to me.

**MainActivity**

```
package com.example.navigationcalculator;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.navigationcalculator.MESSAGE";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

/** Called when the user clicks the Agree button */
public void wind_input(View view) {
    Intent intent = new Intent(this, GetWind.class);
    startActivity(intent);
}

/** Called when the user clicks the Input Navigation Data button */
public void input_nav_data(View view) {
    Intent intent = new Intent(this, InputNavData.class);
    startActivity(intent);
}

/** Called when the user clicks the Calculate Data button */
public void calculate_data(View view) {
    Intent intent = new Intent(this, CalculateData.class);
    startActivity(intent);
}

}

```

**GetWind**

```
package com.example.navigationcalculator;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import static android.content.ContentValues.TAG;
import static com.example.navigationcalculator.R.id.direction_1000;

public class GetWind extends Activity {

public static final String PREFS_NAME = "com.example.myfirstapp.sharedPref";

public final static String DIR_1000 = "com.example.myfirstapp.DIR_1000";
public final static String SPEED_1000 = "com.example.myfirstapp.SPEED_1000";

SharedPreferences sharedpreferences;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_get_wind);

}

//Read all wind speeds and directions and put them in a shared preferences file
public void input_nav_data(View view) {
    Intent intent = new Intent(this, InputNavData.class);

    sharedpreferences = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);

    startActivity(intent);

    // 1000 feet
    EditText dir_1000 = (EditText)findViewById(R.id.direction_1000);
    int direction_1000 = Integer.parseInt(dir_1000.getText().toString());

    SharedPreferences.Editor editor = sharedpreferences.edit();

    editor.putInt(DIR_1000,direction_1000);
    editor.commit();

    int shared_dir_1000 = sharedpreferences.getInt(PREFS_NAME,direction_1000);
    String SD1000 = String.valueOf(shared_dir_1000);
    Log.d("direction 1000",SD1000);

}
}

```

**InputNavData**

```
package com.example.navigationcalculator;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import static com.example.navigationcalculator.GetWind.PREFS_NAME;
import static com.example.navigationcalculator.R.id.direction_1000;

public class InputNavData extends Activity {

public final static String altitude_static_string = "com.example.myfirstapp.altitude";

SharedPreferences sharedpreferences;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_input_nav_data);

}

//Read all navigation data and pass them through as a string to activity CalculateData
public void calculate_data(View view) {
    Intent intent = new Intent(this, CalculateData.class);

    sharedpreferences = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);

    startActivity(intent);

    // Read the actual altitude
    EditText alt = (EditText) findViewById(R.id.altitude);
    int altitude = Integer.parseInt(alt.getText().toString());

    SharedPreferences.Editor editor = sharedpreferences.edit();

    editor.putInt(altitude_static_string,altitude);
    editor.commit();

    int shared_altitude = sharedpreferences.getInt(PREFS_NAME,altitude);
    String SALT = String.valueOf(shared_altitude);
    Log.d("altitude",SALT);

    int PHI = sharedpreferences.getInt(PREFS_NAME,direction_1000);
    String phi = String.valueOf(PHI);
    Log.d("dir 1000 in inputnavdata",phi);
}

}

```