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.
Related
It is possible in Android to load a complex website stored in a folder inside assets android folder... with html, javascript, folders with css files, images etc...? Can't find any info about this in google.
Which is the best approach to achieve this?
Which limitations will have this?
Thanks
You can and you can download awd IDE to do it. It creates a folder and you allows you to creates html/js/css/php files
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
I need 6 large images in my app. And I don't need the quality and alpha channel provided by PNG. Is there a way to embed JPEG files into the raw resource and unfold them into SD card at first launch of the program? It will save me 3-4 MB in my APK. Thanks!
It's very easy. Put your file in res/raw filder and use:
InputStream is = getResources().openRawResource(R.raw.image);
BitmapFactory.decodeStream(is);
You can simply open the stream and do whatever you want with the data.
I think I don't understand your question: It seems that you want to hive off image files at first run...
Anyway, I suggest to put the files in the assets folder and not in the resource. You can access the assets as a file system and copy them to any (permitted) location.
Have a look here:
Difference between /res and /assets directories
and here (look at assets):
http://developer.android.com/tools/projects/index.html
EDIT:
My answer suggests to use assets instead of the resources but, you can't modify your apk at runtime, look here:
how we can remove a file from the assets folder at runtime in android?
Nothing prevents you to put JPEG images in the resource folders, or in the assets folder if you don't need the R.drawable.MY_IMAGE thingy.
However, the images would still be included in your APK, and cannot be removed from your application package even after you copied them to the SD card.
The only way is to download the images separately from a web server on your application first launch.
The Google Play Store also provides some facility if your application needs big files, but that seems a bit of an overkill
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.
I need to provide a zip file (~4-5MB) as a bundle for my app, so I want to include it in my Android project.
The only way I found to achieve this is to put it inside the raw folder or alternatively inside the assets folder, that seems to be the preferable choice, but... this folder is limited up to 1 MB for compressed files.
So... I'd like to know which is the best way to do that. I have to use the raw folder instead the asset one, and why? Or you can suggest me another way to put this file inside the asset folder?
actually, there is a workaround that works nicely with the 1MB-limitation. Give your bundle a mp3 extension and load it from assets. Then unzip it from your application. Note that this is a workaround and not an official solution.
Best way would be to split the file and put the pieces together when you load it.