Bug? Strange behavior of Assets (not updating / refreshing)

Cadenzo

Active Member
Licensed User
Longtime User
It is a project with B4XPages. (if it is important)
I know that it is a mistake to use things like file.exists with assets. But in this case I just want to read a text file.

I changed the text in the asset (same filename, new text), but when reading it shows the old text.
I deleted the asset and add it new in the IDE. In the "files" folder there is the new text and when opening in IDE "Open with default program" it shows the new text.
Also tried "clean project", "restart ADB Server" and closing the IDE.

But when opening the asset file in code, there is still the old one.
B4X:
Sub Button2_Click
    Dim sABC As String = File.ReadString(File.DirAssets, "abcTest1.txt")
    Log(sABC) 'still old text (not the one in asset file)
    pgPlay.Show(sABC)
    'B4XPages.ShowPage("pgPlay")
End Sub
 

Cadenzo

Active Member
Licensed User
Longtime User
Also the problem with new files. I put "abcjs_test3.html" th the "shared files" folder and after sync it is also in the "Files".
There is no warning in code line 2, that the file could not exist.
Asset not found:
Sub Test
    Dim sHtml As String = File.ReadString(File.DirAssets, "ABCJS_test3.html")
    webNoten.LoadHtml(sHtml)
End Sub
But than the error when trying to read the asset string.

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
PgPlay Initialize
** Activity (main) Resume **
PgPlay Created
Error occurred on line: 49 (xPgPlay)
java.io.FileNotFoundException: /data/user/0/eu.vivamusica.pv/files/virtual_assets/abcjs_test3.html (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:200)
    at java.io.FileInputStream.<init>(FileInputStream.java:150)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:204)
    at anywheresoftware.b4a.objects.streams.File.ReadString(File.java:276)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    ...
 

Attachments

  • AssetProblem.JPG
    AssetProblem.JPG
    24 KB · Views: 157

Pendrush

Well-Known Member
Licensed User
Longtime User
Always use lowercase for file name and extension.
That will solve all your problems.
As both Android & iOS are case sensitive OS, but no matter what, always use lowescase.
 

Cadenzo

Active Member
Licensed User
Longtime User
Thank you for response, would be great, if just using lowercase will solve it. If so, there should be a warning with uppercase letters in assets. It would save a lot of time. I will try it.
 

Cadenzo

Active Member
Licensed User
Longtime User
Yes, they are all lower case in the files folder (not in the IDE, as you can see on the picture). So this is not the problem. But where and why is located the information about old textfiles, when they are already updated (with different text) in the files folder? And how I can restore it, to let the system know about the new text?
 
Top