Skip to content

Inconsistent behavior of getAppHomePath() #2551

@jsfan3

Description

@jsfan3

Hi,
do you remember the unsolved bug #2486? The problem was that on iPhone X the images stored inside the app are lost after every app upgrade (while on Android this bug is absent).

After one month and half, I found the cause of the bug and the solution. The cause is not the zero length file size of the images as we supposed... there is a completely different reason for which all my app images are lost after every app upgrade.

The problem is this line:
String pathAvatar = getAppHomePath() + System.currentTimeMillis() + ".jpg";
because getAppHomePath() returns a different value after an app upgrade (on iPhone X), with the result that the previously saved images become unaccessible.

To be sure that my hypothesis is correct, I wrote this three-lines test case:

Form hi = new Form("AppHomePath", BoxLayout.y());
hi.add(new SpanLabel("FileSystemStorage test - The AppHomePath is:\n\n" + FileSystemStorage.getInstance().getAppHomePath()));
hi.show();

At the first app execution, I got that the AppHomePath is:
file:///var/mobile/Containers/Data/Application/FFB4ED3C-A6B1-46E8-B7F1-966EAD62C5C6/Documents//

After reinstalling the same test-case app (WITHOUT uninstall it before, so it's like an upgrade), I got that the AppHomePath is:
file:///var/mobile/Containers/Data/Application/A5DC9A5A-D6FB-4B7E-BC70-37C9C3613C84/Documents//

After discovering this issue, the solution of the bug was obvious: I replaced the use of FileSystemStorage with the use of Storage to save the images, and now my app can access its images after any upgrade.

HOWEVER, is this unexpected behaviour of getAppHomePath() a bug or not? And is it documented?

Thank you for your support

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions