Java nullpointer exception

PFlores81

Active Member
Licensed User
Longtime User
I had this working flawlessly last night. I was exhausted and do not really remember what else I may or may not have added to it. Upon returning to the project to complete it, I get a java nullpointer exception. No idea what I could've done.

Any input is greatly appreciated.


B4X:
Sub Limbs_LongClick

Msgbox("Copying requested file to your external media storage", "Set As")

Try
   File.Copy(File.DirAssets,"limb2.mp3",File.DirRootExternal & "/media/audio/ringtones","limb2.mp3")
      Catch
End Try
u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "limb2.mp3", "LostLimbs", True, True, True, False)
rm.SetDefault(rm.TYPE_RINGTONE, u)
Msgbox("Copy & Set Completed","DONE")
End Sub
 
Last edited:

mc73

Well-Known Member
Licensed User
Longtime User
At first run, you add your file to the media store. Thus, you shouldn't have an error (except if you forgot to make the directory needed, in case it doesn't exist).

BUT, when you run your program again, your file is already stored in the mediaStore, and I think this is the problem with the command u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "limb2.mp3", "LostLimbs", True, True, True, False)
rm.SetDefault(rm.TYPE_RINGTONE, u).

Thus, in case this is not a bug of the object, you should catch the error of overwriting the same file, with try&catch and your command inbetween.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
At first run, you add your file to the media store. Thus, you shouldn't have an error (except if you forgot to make the directory needed, in case it doesn't exist).

BUT, when you run your program again, your file is already stored in the mediaStore, and I think this is the problem with the command u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "limb2.mp3", "LostLimbs", True, True, True, False)
rm.SetDefault(rm.TYPE_RINGTONE, u).

Thus, in case this is not a bug of the object, you should catch the error of overwriting the same file, with try&catch and your command inbetween.

Yeah, I just caught that.. I went in on my test device and removed all the clips from the media storage.. tried it again for long hold and bam there it was.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Never mind.. had to reread what you had posted.. I thank you once again.
 
Last edited:
Upvote 0
Top