Reputation: 99
My Android project contains some property files in the package structure. To read this property I use MyClass.getResourceAsStream("someProperties.xml")
. MyClass has no access to a Context.
After migrating to Android Studio the someProperties.xml
is not moved into the resulting package structure. Therefore my code can't find the file.
What can I do to read my file again? How can I modify the gradle build to have the file copied to my package structure again or is the a possibility to read resources without a context and put the file into assets
?
Upvotes: 2
Views: 267
Reputation: 41
I guess you have not specified within gradle where those resources are located. Defaults are different in Eclipse ADT and Android Studio.
Here are defaults for Eclipse (when java sources already in src/main/java
)
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
see MAKE ANDROID ECLIPSE PROJECT READY FOR ANDROID STUDIO, YET KEEPING IT ACCESSIBLE FOR ECLIPSE USE TOO
Upvotes: 1