Skip to content

Android RootURI may not exist when used for storage #3207

Closed
@PaulDotSH

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

When creating a new file on storage.Child(ROOTURI, "file.json"), on desktop this works as expected but on mobile this uri links to app.pkg.id/fyne/file.json instead of app.pkg.id/file.json

How to reproduce

Try to write to a file in android and desktop version of a fyne app using something similar to
storage.Child(fyne.CurrentApp().Storage().RootURI(), "foo.json")

Screenshots

No response

Example code

func saveState() error {
	uri, e := storage.Child(fyne.CurrentApp().Storage().RootURI(), "foo.json")

	if e != nil {
		return e
	}
	return writeToFile(uri, []byte("Foo"))
}

func writeToFile(path fyne.URI, content []byte) error {
	w, e := storage.Writer(path)

	if e != nil {
		return e
	}
	_, e = w.Write(content)
	if e != nil {
		return e
	}
	return nil
}

func init() {
fmt.Println(saveState()) //file:///.... pkg.app.id/fyne/foo.json not found
}

Fyne version

2.2.2 (latest at the time of writing this)

Go compiler version

1.19

Operating system

Other (specify below)

Operating system version

Arch Linux and Android 10, replicated on android 8 too

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

blockerItems that would block a forthcoming releasebugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions