title: Save change String on restart in Android
body: <p>Im building an app where I have an Array list with strings and a button.
  When I press the button it deletes the string from the list (with string.remove) and display it in another activity..
  The problem is that when I close the app and reopen it everything goes back to normal. How to save the changes made?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>     public class TasksActivity extends AppCompatActivity {
  
  private static ArrayList&lt;String&gt; list;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.activity_tasks);
  
      final Button tasksbtn = (Button) findViewById(R.id.btnfortasks);
      Button checkTask = (Button) findViewById(R.id.remove_case);
  
      final TextView tasksView = (TextView) findViewById(R.id.tasks_textView);
  
  
  
      final ArrayList&lt;String&gt; tasks = new ArrayList&lt;String&gt;();
      tasks.add("one");
      tasks.add("two");
      tasks.add("three");
      tasks.add("four");
      tasks.add("five");
      tasks.add("six");
  
  
  
  
  
      Collections.shuffle(tasks);
      tasksView.setText(tasks.get(0));
  
  
      assert tasksbtn != null;
      tasksbtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Collections.shuffle(tasks);
              tasksView.setText(tasks.get(0));
  
  
          }
      });
  
  
  
      checkTask.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(TasksActivity.this, CompletedTasks.class);
              intent.putExtra("completedTasks", tasks.get(0));
              tasks.remove(tasks.get(0));
              startActivity(intent);
  
          }
      }); 
  
  
  }
  
  
  
   }
  </code></pre>
  
  <p>And the second Activity</p>
  
  <pre><code>    public class CompletedTasks extends AppCompatActivity {
  
  String completedTasks;
  Global_Variable object = new Global_Variable();
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_completed_tasks);
  
  
      TextView completedTasksView = (TextView) findViewById(R.id.completed_tasks);
  
  
      Intent intent = getIntent();
  
      completedTasks = intent.getExtras().getString("completedTasks");
      object.tasks.add(completedTasks + "\n");
  
  
  
      String a = "";
      for (int i = 0; i &lt; object.tasks.size(); i++) {
          a += object.tasks.get (i);
          completedTasksView.setText(a);
          Log.d("a", "a---------" + a);
  
  
      }
  
  }
    }
  </code></pre>