Android : Assets Dir And Multi Language
Solution 1:
That is the expected behavior. Resources in res/
can be localized in that manner, but the assets/
directory cannot.
Since it's just a changelog, I'd recommend storing it as a localized string resource in res/values-LOCALE/
. If you really want localization of assets, you could manually recreate it by getting the current locale and loading, e.g. assets/changelog-en
, vs. assets/changelog-it
, but I think that would generally not be a good idea, and it certainly isn't necessary in your case.
Solution 2:
Try this:
- put both changelog files into assets folder:
Path is for example: assets/en/changelog_file and assets/it/changelog_file
- enter this into your values/strings.xml:
<string name="changelog_file">file:///android_asset/en/changelog_file</string>
- put in your values-it/strings.xml:
<string name="changelog_file">file:///android_asset/it/changelog_file</string>
Like this you can call the string from the code: getResources().getString(R.string.changelog_file) and it will call the values-en or values-it according to device locale.
Post a Comment for "Android : Assets Dir And Multi Language"