title: Shared Preferences is not working, android?
body: <p>The following method was working, but now it is not writing my integer into file. </p>
  
  <pre><code>public void writeChpNum(int num) {
      SharedPreferences prefs = context.getSharedPreferences("myPrefsKey", Context.MODE_PRIVATE);
      prefs.edit().putInt("chapter", num).apply();
  }
  </code></pre>
  
  <p>and this is how I get from Main class:</p>
  
  <pre><code>SharedPreferences prefs = this.getSharedPreferences("myPrefsKey", Context.MODE_PRIVATE);
  chapterNum = prefs.getInt("chapter", 1);
  </code></pre>
  
  <p>Method did not work in this situation:</p>
  
  <pre><code>writeChpNum(1);
  writeLastLine("0");
  
  boolean deleted = file.delete();
  boolean deleted2 = file2.delete();
  boolean deleted3 = file3.delete();
  boolean deleted4 = last.delete();
  android.os.Process.killProcess(android.os.Process.myPid());
  System.exit(1);
  </code></pre>
  
  <p>Here, I want to restart everything and exit, so I am removing files, but for chapters I just have to write "1"-chapter. However, it did not write.</p>
  
  <p>Is this because I am exiting the app?</p>