change the language of the raw folder - android

I have in my project raw folder with several mp3 within.
I want, depending on the language of the phone, using a mp3 or other
in the "values", I can change the language (values_en, values_es, etc) ... but as I do with the raw folder?
I appreciate any help
thanks and regards

As described in this answer, it seems like it isn't supported, but has some workarounds:
localization of assets files

Related

How to handle localization of audio files or other assets in flutter?

I have some audio files that contain speech in the specific language. Let's say default is english and I also have french audio files. In native Android I have different folders for these files in my res folder. For example raw (contains default files) and raw-fr (contains french).
In code I only call play(sound.mp3) and Android uses the correct file for the language that this user has chosen.
Is there already a similar way for this on Flutter?
(It is not a big problem to do this by myself, but of course it would be easier if Flutter has some mechanic for this. I am planning to create folders in my assets folder for each language and create a class that is setting the prefix depending on users device language)

Android translation texts not showing on app

In my app I support 2 languages: English and Hebrew. I created a file strings.xml inside the folder values/ and there are all the English strings. I also created a file strings.xml inside values-he/ folder with the hebrew translations.
But when opening the app in a phone which locale is Israel/hebrew, the user doesn't receives the translation, but only the English texts..
Is there something I'm missing? Do I have to do another thing?
Thanks!
Not only you need the folder
values-he
You also need the folder
values-iw
Because some devices recognize he, some others iw.
So, put the very same files in both folders and you'll have no problems.

More folders in raw folder

So guys, I have a lot of mini sounds in mys application, but it would be a lot easier if I could organize them in folders like \res\raw\foldername. I tried it but i can load only from R.raw and it shows only samples from "raw" folder. Any idea how to do this?
Thanks
I'm not sure if you can do this with raw, but and alternative solution would be to put the files organized into directories, into assets folder, and then read from there.

Can I create folder for storing files besides RAW folder?

can i create folders, besides raw folder, for storing different kind of files?
For examples, my application need to count all the images put in a folder.
So, I need a specific folder for images only, and other folders for sounds, for .txt etc!
But when i tried to create a new folder, I couldn't reach it :(
It is just a hunch, but you might have more luck using the assets folder instead. You can certainly use it to store embedded web sites which have subfolders.
In general you cant create custom resource folders. But you can use assets dir and place your resources there. You can make as much subfolders in assets dir as you need. But android won't help you to manage your files in assets dir. Read this.

How to access resources (like sound, images etc) directly from native code using Android-NDK?

I want to know that how can I directly access the resources like images, sound files etc. from native code i.e. C++ files. Actually I am looking for any example that could help me to use the asset_manager_jni.h methods.
Looking for suggestions. Thanks in advance.
With Regards,
Atul Prakash Singh
Well, you have access to stdio.h. So if it's in a known place (say on the SD card), you can just use that as a path. And there's lot's of tutorials on the net about hot to use stdio (fopen, fclose, etc).
The issue is that resources you bundle into the apk itself (either in res/raw, or assets), stay inside the apk after install. What's worse is that by default, they will be compressed which makes reading it not feasible. This can be avoided, and the easiest way is to rename the asset to have the .mp3 extension (or there are others). The reason for this is because by default, .mp3 is not compressed, regardless of whether or not it actually is an mp3 file). There are other extensions you can use, and ways to tell the tools not to compress your data if you don't like naming all of your assets with .mp3 at the end.
So, you have a few choices here:
Download your resources from the net on your first run, put them in an unobtrusive place (it's probably best to get that path from the sdk when you do the downloading), and use that.
Store your resources in the apk (remember the .mp3 extension, in the assets folder). On your first run, extract the assets to a folder you have access to (and doesn't annoy the user), and use the resources from there.
(what I do) Store your resources in the apk (.mp3 again), and use the jni to read directly from the apk. Yes, the jni is a bit slow, but you shouldn't be reading from the file system all that much anyway, and certainly not at a performance critical point. Nvidia has some very helpful code you can use, you can find it here, it's in the sample code if I remember. Inside the libs folder are some good general purpose libraries you can use that matches stdio, except it also reads from the apk itself.
Hope it helps.
I did use this trick once :
mv $file lib/lib%${file}.so

Categories

Resources