Update: I renamed the original 3 files back to their old filenames and suddenly the program sees them again. I now have 17 music files acknowledged by the program. Still, the question remains: why? Why does something as mundane as renaming a file suddenly prevent the app from even seeing it?
Okay, so I'm making a program with features including a) counting the number of files in a folder, and b) listing the names of those files on screen.
I started simple, with three files. And it worked. The app picked up on all three files, displayed their names on screen (and even loaded and played them, as they were music files).
But I've designed this thing to adapt to changes in the directory. So to really test it I used a file explorer to manually add 14 more music files, so the total should've been 17. So I closed the app and restarted it. Problem is: only fourteen files show up. What's missing? The original 3. All I did was add files to the directory and rename the original 3, and for whatever reason, the app started glossing over the original three files that it was picking up on just fine before. I even modified the loop to actually tell me how many files were in the directory and it says 14. The app literally just doesn't count these specific files. Anyone else run into stuff like this? I don't think renaming the original 3 files should've done anything because the code is designed to not even really be aware of the file names other than to search for them. I even tried uninstalling and reinstalling the app, and deleting all music files and copying them back in all at once. No change.
This is what I have so far. For the record, I'm trying to make a media player. I've only been seriously working on it for about a week. It should provide great help to anyone learning to access files on Android...
One last thing: any time I export the code into an .APK and install it on my phone, the first time it runs it always fails because it has to ask me permission to access files/folders. But I close it and run it again, and it's fine.
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
rem figure out how many files are in the folder
amount# as integer
amount# = getrawfoldernumfiles(openrawfolder("raw:/sdcard/Music"))
rem make a list of files in the folder
for a = 1 to amount#
tracklist$[a] = getrawfolderfilename(openrawfolder("raw:/sdcard/Music"),a-1)
rem set track variable
track# as integer
track# = 1
for a = 1 to amount#
if getmusicplayingogg(1) = 0
track# = track# + 1
if track# > amount# then track# = 1
if getmusicexistsogg(1) then deletemusicogg(1)
song$ = "raw:/sdcard/Music/" + tracklist$[track#]