Save an online mp3 to your app's raw folder - android

I have been searching around and can not seem to find a way to download a media file from my website and save it to my app's raw resource folder. What is the best way to do this? Any help is greatly appreciated.

You can't access resource folder once your app is installed. So you can't access raw folder for WRITE after installation. So better to use internal storage to store this file.

You cannot do that, you can only read from the 'raw' and 'assets' folders. Either use internal storage, or if relevant - APK Expansion Files.

Related

How can i insert a .bin created on desktop file into apk

I have code for creating an internal file, there is random algorithem that create the data stored in it and i want any app to have the same file with the same binary data in it.
so i need to make the file on my desktop and add it to internal files some how.
my question is what do you think is the best way to do it.
i thought to locate it in my project, read it, and write it to internal files.
the problem is, i dont know where to locate my file in android studio so that it will be included in the external files and then where to read it from.
thanks. =]
hope i made myself clear.
Put it in src/main/assets/.
You can then access your file with AssetManager and do whatever you want with it.
From the Android Developers website:
main/assets/
This is empty. You can use it to store raw asset files. Files that you
save here are compiled into an .apk file as-is, and the original
filename is preserved. You can navigate this directory in the same way
as a typical file system using URIs and read files as a stream of
bytes using the AssetManager. For example, this is a good location for
textures and game data.
You need to move that into the assets folder. From there you can refer to the file.

How to access files which is stored in custom folder of internal storage using external app?

I have a zip file. I am unzipping it to internal storage. When unzipping each file, I am keeping the same folder structure. After unzipping all levels, I want to display the files using appropriate third party apps like adobe reader etc.
I can unzipping and creating files with same folder structure. But the problem is the files could not be displayed through external app, because of permission. I couldn't set WORLD_READABLE PERMISSION, because the files are storing in custom folders. I applied setReadable also. But no hope.
How can I show files, or how to get permission to files?
Any help would be appreciated..
Thanks
Jomia
Use FileProvider to serve up the files from your app's internal storage using a ContentProvider.
Or, put the files on external storage, instead of internal storage.

How to put a *.cfg file to the same directory as the *.apk file?

I am really new to android devices, we have got an app that needs to read a *.cfg file from the same place as the apk. So the question is:
1) When i attach my mobile-phone to the computer, can i put it from the explorer? If yes, how?
2) Is there a mechanism in Android, that looks for some kind of include directories
when opening a Program?
It would be great if you could give me a hint.
You'd want to drop the *.cfg files into the assets/ folder. Then the app will have access to those raw *.cfg files during runtime.
From Managing Projects
assets/
This is empty. You can use it to store raw asset files. Files that you
save here are compiled into an .apk file as-is, and the original
filename is preserved. You can navigate this directory in the same way
as a typical file system using URIs and read files as a stream of
bytes using the AssetManager. For example, this is a good location for
textures and game data.

Is Asset folder read-only?

How to write files inside Asset Folder?
It's read only or write?
If any example then please share me.
How to Secure Asset Folder?
or whether we create userdefined foder 7 can access it for browsing like file:///android_assets/www....
No,You cannot write in asset Folder, its read only.
Internal Storage in Android
As the Name says it is has a kind of Supporting files used in it.
Like .ttf file and all.
It is Read Only

Save a (.txt) file to the Assets Folder in Android?

How to write to .txt file in assets folder.
How to get path assets folder ?
You can't. The assets folder is read-only at runtime.
Pick a different location to save your data, see Data Storage for more information.
The path of assets folder is file:///android_asset But this is read-only.
The assets folder is like folders res, src, gen, etc. These are all useful to provide different files as input to build system to generate APK file for your app.
All these are read-only while your app is running. At run-time you can only write to SD card.
I hope you understand my answer.
Not possible,
Better you choose internal storage to save your txt file. Internal Storage. Hope this will help you to understand.
No you can't do this, because of if you read and write both at runtime then everything could be change and application will behave unexpected which could be harmful or may be crashed. i suggest you to use internal memory, sqlite and app SharedPreferences etc.

Categories

Resources