Android assets from linked folder
Asked Answered
G

1

8

I would like to import into Assets folder an external directory, in which there are some files that I need to share across different platform distribution of the same app, basically Html files.

I've tried adding a Linked folder to android project from New-> Folder-> Advanced, using absolute or relative reference. But then

getAssets().open("folder")

Fails, with FileNotFound Exception.

I've tried also command line from assets folder:

ln -s ../../source_folder dest_folder

This creates a new "alias" folder into the filesystem, but Eclipse gets the folder not as a Linked resource but as a normal "Folder". I would go with this solution, but since we are a team of several developers sharing the same project, I believe the alias won't work on all systems, resulting that some files will be saved into the new "aliased" folder, others on the original folder.

In conclusion: is there anyone who came across the same problem? Is there a way, for a team, to reference an external folder as an Android asset?

Grenadine answered 21/5, 2012 at 13:56 Comment(2)
I'd say put the files you need in the folder instead of using different content for each developer, but I guess there is a very good reason for that.Wexford
I think you need to ant you your way out of this, there is a similar post here: #4793720Wexford
R
1

If you are using android studio, you can add your folder to assets folder, like following:

sourceSets {
    main {
        assets.srcDirs += 'your/folder'
    }
}

See here for detail:

Refuel answered 11/4, 2018 at 7:27 Comment(1)
What if I need not a folder, but a single file?Chiropractor

© 2022 - 2024 — McMap. All rights reserved.