I read a tutorial on how to get names of files in an absolute path, but now I want to get all files - for example in my internal storage-
I mean by all the files, the files which are in the folders not only in an absolute path.
for example if my internal have folders and files like that
/music
/videos
/data
mine.png
mohamed.txt
and my music folder have files like
him.png
sir.doc
I want a list like that
mine.png
mohamed.txt
him.png
sir.docx
I hope some one got me.
Thanks
Related
Following are my understanding of them, and want to make sure it's correct.
Assets folder is a directory that I can place files so app can use.
This is immutable folder.
Internal storage is a directory you are given when your app is installed.
You can mutate files under this directory.
If I maintain a read-write sqlite database, I will probably make it here under internal storage.
If I want to provide an initial database though, I would have to place it under the assets folder, and copy it when app is first run.
Yes, your understanding is correct. The difference between the Assets folder and the Internal Storage folder is that the Assets folder can't be changed at runtime. So the usage of internal storage and assets folder is as follows-
1) When one has fixed content like fonts,images,styles,string values,etc. put it into the assets folder.
2) If based on the programme the values must change based on the situation then save those values in the Internal Storage.
Yes you're right. The difference is that assets folder is read only folder. You can put your files there and use them in your app but if you need to change or modify them, you should copy them from assets to internal then do your works, so if you have static texts or fonts or files that needs nochange you can put them in assets folder but if you have database files you should copy ithem to internal.
I am a novice programmer,and encounter a problem in the development of an Android application.I have a subfolder raw under the folder res, now ,i want to traverse the folder raw and get files' name and path in the folder. who can help me?
There are some MP3 files in the raw folder ,and i want to list of their name and get their path for use VideoView to play it. poor English, forgive meļ¼thanks!
If you want to be able to get a list of files shipped with the app, move the files in the assets folder.
For example : if you create a folder in the assets folder called 'video' then you can retrieve a string array with the filenames like this :
String[] filesInAssets = getResources().getAssets().list("video");
I don't see a solution for reading the files under the res folder.
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.
I'm working on an Android application that needs to store media (document files like pdf or so for later reading) but the main requirement is that all media files have to be accesible through an absolute path (a physical path on filesystem).
I'd like to avoid copying files to external storage (like sdcard or phone internal memory) so to prevent that if application is uninstalled those files remain in phone (and of course to avoid duplicating the size in kb for each file) and instead to keep files in iny App internal resources folder, but tried "file:///asset_folder" whith no success. As far as I know "file:///asset_folder" only Works for a webview to Access www folder but not for regular files.
I'm not sure if there is any app internal data folder which I can access through an absolute path or if not which is the best way to store App resource files.
Thanks in advance!!
Edit: To make it more clear, the resource files are already bundled with the App, and not written during runtime, and what I'd like to know is where to put them so I can later Access them via absolute path for Reading.
To retrive your app specific data
openFileInput(file_name)
To save your app specific data
openFileOutput(file_name, Activity.MODE_PRIVATE)
Update : Read from asset folder. (InputStream)
getAssets().open(fileName);
getAssets().open(fileName, accessMode);
check the image to where to put asset files
now to make other app readable your files from private data/data directory use content providers.
You can not write data inside asset_folder because it is packed on apk file. You can use sd card or location where your app is installed inside internal memory.
Suppose I store various images in raw folder. However, my own code first learns of the file names at runtime. (It reads a text configuration file at startup.) Is it possible to then search "raw" folder in my android app and if found, load image from raw into imageview?
Okay, thanks to Mario I got on track to doing some research. These 5 SO's explain everything:
Android images in /assets or res/raw
Reading assets or raw or resource files as a File object in Android
How to reference a File in raw folder in Android
Check for file existence in androids assets folder?
Difference between /res and /assets directories