Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android assets from linked folder

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?

like image 222
sosergio Avatar asked May 21 '12 13:05

sosergio


1 Answers

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:

  • Android Studio: https://developer.android.com/studio/build/gradle-tips.html#change-default-source-set-configurations

  • Gradle: http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.api.AndroidSourceSet.html

like image 105
xfdai Avatar answered Oct 04 '22 08:10

xfdai