Skip to content

How to place file in Android's external storage when installing application. #7009

@Audionysos

Description

@Audionysos

What would you like to be added:

I can't figure out how to place asset files in private external storage on Android.
From what I understand the the assets are embedded somewhere inside the executable/library,
Finally I thought to maybe copy them manually but I can't even access them using Assets.Open() as described in "AboutAssets.txt".
I have following structure in shared project:
Assets/Audio/default/In The Mood.mp3
I've set the BuildAction to Content. On Windows(UWP) the file is placed as expected, in the path relative to executable, and the program works fine.
On android I have no idea where the file is. I've printed all subdirectories from local storage as well as private external storage but I don't see it. So I've tried to open it using example form "AboutAssets.txt"

protected override void OnStart() {
	base.OnStart();

	var input = Assets.Open(@"Audio/default/In The Mood.mp3");
	WriteLine(input.Length);
	input.Close();
}

But the open method says the file is not found.
I can't find any info about the assets except at Assets and image display but it doesn't help.

It would be nice if there was an example of how to deploy the files in external storage when application is installed or at least how can I access any asset file so I could copy it manually.

Why is this needed:

I want the user to be able to place he's own sounds packages easily inside the common directory so it can be chosen instead of default one. For example user will create directories structure in Audio\My Sounds\... which reflects the original structure and then he can simply select "My Sounds" pack in the application's settings.

For which Platform:

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • Windows

Anything else we need to know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.triage/untriagedIndicates an issue requires triaging or verification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions