title: Storing Preferences on a multi user app
body: <p>I am developing an android application. It has two types of users, a teacher and a student. I was hoping to use Shared Preferences to communicate between the two users.</p>
  
  <p>Basically, I have a teach screen which has four TextViews on it with different messages. The TextView text is set to "" when the toggle value is 1 (which is the default value).</p>
  
  <p>On the student screen, they have 4 Buttons. Upon hitting each button, the toggle value is changed to 0 and then the message is displayed on the teacher's view. This works when I log in as a student, click the button, then log in as a teacher. However, I want it to work on two different devices, so that when the student clicks the button the teacher sees the message.</p>
  
  <p>Here are some code snippets:</p>
  
  <p>Firstly, the student activity:</p>
  
  <pre><code>Assistance.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  toggleAssistance(view);
              }
          });
  
  
  
  public void toggleAssistance(View view){
          SharedPreferences sharedPreferences = getSharedPreferences("requestToggles", Context.MODE_PRIVATE);
  
          SharedPreferences.Editor editor = sharedPreferences.edit();
  
          editor.putInt("assistanceToggle", 0);
          editor.apply();
      }
  </code></pre>
  
  <p>Secondly, the teacher activity:</p>
  
  <pre><code>asstToggle = sharedPreferences.getInt("assistanceToggle", 1);
  
  
  if(asstToggle==1){
              Assistance.setText("");
              clearAssistance.setVisibility(View.GONE);
          }
  </code></pre>
  
  <p>Clear assistance is just a button that basically does the reverse of toggleAssistance (it sets the value to 1). No need for this button to be displayed when the message isn't.</p>
  
  <p>Can anyone provide assistance or advice in to how I can make this work between devices? Thanks!</p>