# Save File in APDE

**URL:** https://discourse.processing.org/t/save-file-in-apde/8887
**Category:** Processing for Android
**Created:** [March 3, 2019, 11:50am UTC](https://discourse.processing.org/t/save-file-in-apde/8887 "2019-03-03T11:50:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Janvonfalken](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Janvonfalken](https://discourse.processing.org/u/Janvonfalken)
#### Post date: [March 3, 2019, 11:50am UTC](https://discourse.processing.org/t/save-file-in-apde/8887/1 "2019-03-03T11:50:33Z")

</div>

I am trying to save a highscore in APDE. I am currently trying to create the file

```auto
File highscoreData= new File("//storage/emulated/0/JGameData","highscore.txt");
if (highscoreData.exists()){
      highscore=0;
      highscoreArray = loadStrings("//storage/emulated/0/JGameData/highscore.txt");
      highscore=float(highscoreArray[0]);
      }
      else {
        highscoreData.mkdir();
        highscoreData.createNewFile();
      }
}

```

but I just get an unhandled IOException Error. What am I doing wrong?

---

<div class="post-metadata">

### Author: ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)
#### Post date: [March 4, 2019, 8:49am UTC](https://discourse.processing.org/t/save-file-in-apde/8887/2 "2019-03-04T08:49:37Z")

</div>

@Janvonfalken ====  
i dont use APDE but i think that in this case you can easily avoid this error coding like that:

```auto
File highscoreData= new File("//storage/emulated/0/JGameData","highscore.txt");
if (highscoreData.exists()){
      highscore=0;
      highscoreArray = loadStrings("//storage/emulated/0/JGameData/highscore.txt");
      highscore = float(highscoreArray[0]);
      }
      else {
        highscoreData.mkdir();
         try {
        highscoreData.createNewFile();
         }catch(IOException e){
           println(e);
         }
      }

```

```auto

```

---

<div class="post-metadata">

### Author: ![Janvonfalken](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Janvonfalken](https://discourse.processing.org/u/Janvonfalken)
#### Post date: [March 4, 2019, 9:30am UTC](https://discourse.processing.org/t/save-file-in-apde/8887/3 "2019-03-04T09:30:44Z")

</div>

Thanks for the answer, I tried a catch block but it didnt seem to work, it just didnt throw an error. Doesnt matter though, I solved the peoblem with Shared Preferences.

---

<div class="post-metadata">

### Author: ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)
#### Post date: [March 4, 2019, 10:11am UTC](https://discourse.processing.org/t/save-file-in-apde/8887/4 "2019-03-04T10:11:40Z")

</div>

@Janvonfalken ===  
In this type of case SharedPreferences is the STANDARD simple && good solution!
