I can't figure out the exact sequence of execution for various parts of your code, but the only thing on that line that can generate a NPE is that mediaStorageDir
is null
. Since you initialize mediaStorageDir
after an instance of LoadSingleTrack
asynchronously executes, I can only assume that it is executing after line 324 executes. Resolve this out-of-order sequencing of code execution and the problem should disappear.
Just as a side note: there is no point in calling runOnUiThread
from onPostExecute
of an AsyncTask
; you are already on the UI thread when onPostExecute
is called.