Were there any changes made to the media store in ICS and Jellybean?

PFlores81

Active Member
Licensed User
Longtime User
I have 3 soundboards that give the users the ability to copy and set a specific clip for use as ringer or notification.

The issue I am seeing is largely with ICS, and Jellybean devices.

With gingerbread the code worked fine on the 8 different devices it was tested on.
Code sample below.

B4X:
 If File.Exists(File.DirRootExternal & "/media/audio/ringtones","Round_End.mp3")=False Then 
        
        File.Copy(File.DirAssets,"Round_End.mp3",File.DirRootExternal & "/media/audio/ringtones","ZS_Round_End.mp3")
        u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "ZS_Round_End.mp3", "ZS_Round_End", True, True, True, False)
Else Return
  End If
 

NJDude

Expert
Licensed User
Longtime User
In certain devices that has changed, the path is:
B4X:
File.DirRootExternal & "/audio/ringtones"

But let me stress this, that changes from device to device, some devices have a MEDIA directory others don't.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
In certain devices that has changed, the path is:
B4X:
File.DirRootExternal & "/audio/ringtones"
But let me stress this, that changes from device to device, some devices have a MEDIA directory others don't.


Well then, I'll just have to have the app check for that and if that directory exists it can default to that one. great! lol more time to put it together as I have an update to push anyway. too many requests from users has set me back a bit.

Although I guess I could have it check for the directory, and if that directory does not exist I could have it create it.
 
Last edited:
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Hmmmmm, Erel if you could get me pointed in the right direction. I know how to check for existing files, how do I check for existing folders?

HTC = Hate The Consumer
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Would this be the correct usages for looking for the folder?

B4X:
     If File.Exists (File.DirRootExternal & "/media/audio/ringtones", "")= False Then
     Msgbox("Directory does not exist and will be created for you.", "Directory")
     File.MakeDir (File.DirRootExternal & "/media/audio/ringtones", "")
End If
 
Last edited:
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Your code looks correct. It is slightly better to use File.Combine:
B4X:
If File.Exists(File.Combine(File.DirRootExternal, "media/audio.ringtones"), "") = False Then ...
This way you do not need to worry about the first or last slash.


thanks Erel.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Ok so below is a truncated copy of the code. IF i remove the check for the directory, it completes without issue. however, when i add those few lines back in.. it fails to complete yet nothing is shown in the debugger.

B4X:
Sub Copy_Click
If Msgbox2("This will copy all clips and set them for use in your ringtone and notifications options!","Copy", "Proceed", "", "Cancel", Null) = DialogResponse.POSITIVE Then
            Return False
        Else
            Return True
        End If
     Try
     If File.Exists(File.Combine(File.DirRootExternal, "media/audio.ringtones"), "") = False Then
     
     Msgbox("Directory does not exist and will be created for you.", "Directory")
     
     File.MakeDir (File.DirRootExternal & "/media/audio/ringtones","")
     Else
     
  If File.Exists(File.DirRootExternal & "/media/audio/ringtones","box.mp3")=False Then 
        
        File.Copy(File.DirAssets,"box.mp3",File.DirRootExternal & "/media/audio/ringtones","ZS_Box.mp3")
        u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "ZS_Box.mp3", "ZS_Box", True, True, True, False)
  End If
  
  If File.Exists(File.DirRootExternal & "/media/audio/ringtones","Round_End.mp3")=False Then 
        
        File.Copy(File.DirAssets,"Round_End.mp3",File.DirRootExternal & "/media/audio/ringtones","ZS_Round_End.mp3")
        u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "ZS_Round_End.mp3", "ZS_Round_End", True, True, True, False)
  End If
 Catch
  End Try
  Msgbox("Copy and Setup Completed!","Complete")
     

End Sub
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
You MakeDir instruction is wrong:
B4X:
File.MakeDir (File.DirRootExternal & "/media/audio/ringtones","")
it should be
B4X:
File.MakeDir (File.DirRootExternal, "/media/audio/ringtones")
Best reagrds.


See the first time I tried it that way it gave me an error. I must've overlooked something so I formatted it differently .. Thank you. Ill give that a try.

Ok, the mkdir worked, however it does not copy. I checked the file structure before and after, I check the log file as well. Ran under debug, no errors. If you need me to attach the log file or the project I will.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Below is the portion of code stopping the copy operation. If I remove the folder check in its entirety, the process will complete with no issue.
.

B4X:
If Msgbox2("This will copy all clips and set them for use in your ringtone and notifications options!","Copy", "Proceed", "", "Cancel", Null) = DialogResponse.POSITIVE Then
            Return False
        Else
            Return True
        End If
     Try
     If File.Exists(File.Combine(File.DirRootExternal, "media/audio.ringtones"), "") = False Then
     
     Msgbox("Directory does not exist and will be created for you.", "Directory")
     
     File.MakeDir (File.DirRootExternal, "/media/audio/ringtones")
     Else
 
Last edited:
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Try this:
B4X:
If File.Exists(File.DirRootExternal, "/media/audio/ringtones") = False Then
     Msgbox("Directory does not exist and will be created for you.", "Directory")
     File.MakeDir (File.DirRootExternal, "/media/audio/ringtones")
Else
     ...
End If

Same issue, Will popup the proceed or not msgbox, upon tapping proceed, thats it.. it just stops no error, no directory created, nothing copied, lol Removing the directory check, it works fine.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Why do you have this code?

B4X:
            Return False
        Else
            Return True
        End If

You don't need that if you are just trying to get a response from the msgbox2.

I think your code should look like this:

B4X:
If Msgbox2("This will copy all clips and set them for use in your ringtone and notifications options!", "Copy", "Proceed", "", "Cancel", Null) = DialogResponse.NEGATIVE Then
   Return
End If
If File.Exists(File.DirRootExternal, "/media/audio/ringtones") = False Then
   Msgbox("Directory does not exist and will be created for you.", "Directory")
   File.MakeDir(File.DirRootExternal, "/media/audio/ringtones")
Else
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
Why do you have this code?

B4X:
            Return False
        Else
            Return True
        End If
You don't need that if you are just trying to get a response from the msgbox2.

I think your code should look like this:

B4X:
If Msgbox2("This will copy all clips and set them for use in your ringtone and notifications options!", "Copy", "Proceed", "", "Cancel", Null) = DialogResponse.NEGATIVE Then
    Return
End If
If File.Exists(File.DirRootExternal, "/media/audio/ringtones") = False Then
    Msgbox("Directory does not exist and will be created for you.", "Directory")
    File.MakeDir(File.DirRootExternal, "/media/audio/ringtones")
Else


Was just going by what works. Thank you Margret, I will throw that in there and see if it works. I appreciate the help. This has been driving me nuts for a few days and I know it is a simple fix, just need to find the right line to add or remove.

Edit: It will now create the directory but fail to copy. haha.. if its not one its the other. Ill keep digging , thank you again :)

Edit2: Got it! Thank you for your help Klaus, NJDude, and Margret. You 3 are both extremely helpful and are valuable assets to this site. I hope to repay the favor in the future.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
There are several problems:
- the first Margret already mentioned it, with this code you always exit the routine without doing anything
B4X:
If Msgbox2("This will copy all clips and set them for use in your ringtone and notifications options!","Copy", "Proceed", "", "Cancel", Null) = DialogResponse.POSITIVE Then
  Return False
Else
  Return True
End If
Then you check for media/audio.ringtones but you want media/audio/ringtones so you never copy any file
B4X:
If File.Exists(File.Combine(File.DirRootExternal, "media/audio.ringtones"), "") = False Then
   Msgbox("Directory does not exist and will be created for you.", "Directory")
   File.MakeDir (File.DirRootExternal, "/media/audio/ringtones")
Else
Then you check if file box.mp3 does exist but you copy it as ZS_Box.mp3
B4X:
If File.Exists(File.DirRootExternal & "/media/audio/ringtones","box.mp3")=False Then 
        
  File.Copy(File.DirAssets,"box.mp3",File.DirRootExternal & "/media/audio/ringtones","ZS_Box.mp3")
  u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "ZS_Box.mp3", "ZS_Box", True, True, True, False)
End If
Same for the other files.

You should be more systematic and check carefuly your code.

Best regards.
 
Upvote 0
Top