# File not found when running fmod in background and main application closed/swiped

**URL:** https://qa.fmod.com/t/file-not-found-when-running-fmod-in-background-and-main-application-closed-swiped/19557
**Category:** FMOD Engine
**Tags:** android
**Created:** [November 21, 2022, 9:05pm UTC](https://qa.fmod.com/t/file-not-found-when-running-fmod-in-background-and-main-application-closed-swiped/19557 "2022-11-21T21:05:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dominiknkrs](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dominiknkrs](https://qa.fmod.com/u/dominiknkrs)
#### Post date: [November 21, 2022, 9:05pm UTC](https://qa.fmod.com/t/file-not-found-when-running-fmod-in-background-and-main-application-closed-swiped/19557/1 "2022-11-21T21:05:17Z")

</div>

Hi, unfortunately i have encountered yet another problem I can’t solve. I’m trying to keep fmod playing in the background even when the application is swiped from the user. I’m using a permanent notification with a foreground service to achieve that. Now, it seems to be working with files coming from the application bundle / assets folder, but not when reading files from the private folder (com.my.app/files)…

It’s erroring out with `FMOD error 18 - File not found.` (even though the file exists and can be read if I restart the app and play it while it’s open… Could anybody give me some hints as to what I’m doing wrong?

I was thinking that the context passed in is not valid anymore when the application is swiped, but then why would it keep working only with the assets folder file?

This is how I’m calling FMOD.init:

```java
      for (String lib: BuildConfig.FMOD_LIBS)
      {
        System.loadLibrary(lib);
      }
      System.loadLibrary("my_native_lib_using_fmod");
      org.fmod.FMOD.init(context.getApplicationContext());

```

where context is [a wrapper on the application context](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java)

---

<div class="post-metadata">

### Author: ![dominiknkrs](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dominiknkrs](https://qa.fmod.com/u/dominiknkrs)
#### Post date: [November 22, 2022, 9:08pm UTC](https://qa.fmod.com/t/file-not-found-when-running-fmod-in-background-and-main-application-closed-swiped/19557/2 "2022-11-22T21:08:52Z")

</div>

correction for the code:  
this is how I’m calling init (in a Service subclass)  
org.fmod.FMOD.init(this)

---

<div class="post-metadata">

### Author: ![dominiknkrs](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dominiknkrs](https://qa.fmod.com/u/dominiknkrs)
#### Post date: [November 27, 2022, 1:23pm UTC](https://qa.fmod.com/t/file-not-found-when-running-fmod-in-background-and-main-application-closed-swiped/19557/3 "2022-11-27T13:23:17Z")

</div>

solved. i was missing a jvm-\>AttachCurrentThread

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [November 27, 2022, 11:44pm UTC](https://qa.fmod.com/t/file-not-found-when-running-fmod-in-background-and-main-application-closed-swiped/19557/4 "2022-11-27T23:44:21Z")

</div>

Thank you for sharing the solution!
