Android Question Android Information for Newbies - Like me

AlexOfOz

Active Member
Licensed User
I post information as I bump into it for people who are so new, they are too timid to ask the question. I understand entirely and have no shame ..... If I don't know, I'll ask.

This is to do with Android not differentiating between upper and lower case.

I am currently working on an app for an Android phone that has lots and lots of mp3 files that I have obtained from GITHUB. Their names contain both upper and lower case and worked beautifully with B4J.

However, when I came across to build a similar app on my Android phone, I ran into all sorts of frustration associated with DirAssets. Even after renaming every file to remove all upper case, the problem continued to happen.

Eventually I eliminated all possible sources of continuing problems, but was still facing the same frustration. That's when it occurred to me that the phone might be holding on to the existing files in DirAssets and, because it doesn't recognise the difference between upper and lower case, wasn't replacing them, no matter how hard I tried.

The answer was to turn the phone off, then restart it. In doing so I must have cleared DirAssets, allowing the next run of the program to reload the now all lower case mp3 files. And it worked.

I hope this has helped a silent person out there.

Alex
 

teddybear

Well-Known Member
Licensed User
I wonder which folder mp3 files you obtained are put into, DirAssets?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

AlexOfOz

Active Member
Licensed User
The name of all files in DirAsset it seems to have been converted to lowercase by B4A, so I asked that
No, it appears that the names of the files weren't converted to lower case. I did a ListFiles on DirAssests and the mp3's were all there in upper and lower. That was one of the things confusing me, because when I tried to load new, lowercase file names, Android said they were already there and didn't replace them. Very confusing.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

teddybear

Well-Known Member
Licensed User
No, it appears that the names of the files weren't converted to lower case. I did a ListFiles on DirAssests and the mp3's were all there in upper and lower. That was one of the things confusing me, because when I tried to load new, lowercase file names, Android said they were already there and didn't replace them. Very confusing.
It's weird, I don't think they are case sensitive in DirAssests, do you play mp3 that is in DirAssets?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
when I tried to load new, lowercase file names, Android said they were already there and didn't replace them.
I don't understand what you mean, why said they were already there and didn't replace them.
 
Upvote 0

AlexOfOz

Active Member
Licensed User
I don't understand what you mean, why said they were already there and didn't replace them.
They were already in DirAssets as upper and lower case, but when I renamed them in the program to be all lower case, then reran the program, Android saw the names in DirAssets - the upper and lower case ones - as being the same as those in the program - the lower case ones. And because it thought they were the same it didn't bother replacing the ones in DirAssets. That is the final point of my original post; in order to clear them out of DirAssets, I needed to turn the phone off then back on. That cleared DirAssets of the upper and lower case mp3's, allowing the new lower case ones to be written to DirAssets when I ran the program again.
 
Upvote 0

AlexOfOz

Active Member
Licensed User
Rename, how do you do rename?
The mp3 modules are hard coded in the program. Button 32 uses abc.mp3. The name of the modules was a tad convoluted when I downloaded them, but the module's use was coded into the name, so I didn't change it. The only change I made was to change all upper case to lower case .... in the program files and in the program. The final step was to remove them from DirAssets, as discussed above.

This journey of identifying the root cause of the problem, then determining the numerous steps I needed to take to over come it was long, frustrating, but ultimately fruitful. I've learned a lot and hopefully this post can remove some of the time and angst for others. I have seen that I'm not the first to bump into this situation, and I have read some joyful accounts of "clever" ways of getting past it. I always prefer the simple approach if there is one, and having everything lower case for Android is the simple solution, but it only works if the DirAssets is cleared of the earlier upper and lower case ones.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I think cleaning the project in the B4A IDE before you compile will also force the assets to be re-copied (but I could be wrong).

Fyi - Android filenames *are* case sensitive but the OS will ignore case when handling files from case insensitive file systems.

- Colin.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
The mp3 modules are hard coded in the program. Button 32 uses abc.mp3. The name of the modules was a tad convoluted when I downloaded them, but the module's use was coded into the name, so I didn't change it. The only change I made was to change all upper case to lower case .... in the program files and in the program. The final step was to remove them from DirAssets, as discussed above.
Thank you for sharing the solution.
I couldn't find rename method in File, so I was curious to ask you how do rename, after read this, I guess it is that copy mp3 to another folder then delete it from assets, is that?
 
Upvote 0

AlexOfOz

Active Member
Licensed User
Thank you for sharing the solution.
I couldn't find rename method in File, so I was curious to ask you how do rename, after read this, I guess it is that copy mp3 to another folder then delete it from assets, is that?
In simple words, yes. The rename of the mp3 modules was done on the laptop, not within the program. Of course, all references to them in the program needed to be made lower case, but that wasn't how I changed the names. It was simply a case of renaming every one in the laptop folder, then adding them to the program in the standard way.
 
Upvote 0

RodM

Member
Licensed User
They were already in DirAssets as upper and lower case, but when I renamed them in the program to be all lower case, then reran the program, Android saw the names in DirAssets - the upper and lower case ones - as being the same as those in the program - the lower case ones. And because it thought they were the same it didn't bother replacing the ones in DirAssets. That is the final point of my original post; in order to clear them out of DirAssets, I needed to turn the phone off then back on. That cleared DirAssets of the upper and lower case mp3's, allowing the new lower case ones to be written to DirAssets when I ran the program again.
You know that DirAssets is read only, don't you? You can't rename, or change any files there, within the app.
 
Upvote 0

AlexOfOz

Active Member
Licensed User
You know that DirAssets is read only, don't you? You can't rename, or change any files there, within the app.
I certainly do now, that's for sure. Now it is clear that also includes replacing existing files in there, or deleting files from there, hence the need to turn off the phone to clear it. The main point of this post was to highlight the confusion that can come from Android not accepting upper and lower case and the weird way it handles it. So long as people know about this potentially confusing situation, they'll know what to do if their files aren't working. Rename them on the laptop to all lower case, then turn the phone off and back on. Run the program again from the laptop and it will reload the renamed files and Android will handle them correctly.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
I had a similar problem here

 
Upvote 0

Adrian Jansen

Member
Licensed User
Longtime User
Not directly related, but you might find its better to put the names of all files you want to use in a list, adjusting cases as needed. Put the file list in DirAssets too, and then read that first. That way you dont have to hard-code filenames in your code. Much more flexible.
 
Upvote 0

AlexOfOz

Active Member
Licensed User
Not directly related, but you might find its better to put the names of all files you want to use in a list, adjusting cases as needed. Put the file list in DirAssets too, and then read that first. That way you dont have to hard-code filenames in your code. Much more flexible.
Excellent idea. Thanks for the suggestion. I did a similar trick for my home-grown WORDLE program. Not DirAssets, but a place that makes it very convenient.
 
Upvote 0
Top