This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Can The Android drawable directory contain subdirectories?
How to organize graphics/java/xml file in folders in android project in eclipse?
I mean - should I (to store graphics) create folder in my 'drawable-mdpi' or as a separated folder?
I tried making folder in drawable and calling file by:
#drawable/photo/fileName
also tried making separate folder in /res, and call by:
#photo/fileName
but with no success.
should I (to store graphics) create folder in my 'drawable-mdpi' or as a separated folder?
Sadly, you cannot create your own file structure in the /res folder... You must use the existing folder structure, like /res/drawable-mdpi and use R.drawable.xxx.
You can read about this "bug" here: Android layout folder organization or read the brief explanation straight from a lead Android programmer: Can The Android drawable directory contain subdirectories?.
You don't need/can't use a separate folder. Just put in each drawable folder and access with #drawable/filename with no extension
Related
This question already has answers here:
Where to put text files in directory in Android
(3 answers)
Closed 4 years ago.
In Android Studio, If we want to use an image in our Anroid app, we move this image to res/drawable file. And we use it.
But if we want to use contents of a .txt file (e.g reading text from file at the first launch the app), which directory should we move this file?
You can put it on res/raw or in assets/ directory.
Just create folder assets like this:
Or create folder raw in res and you can put there whatever you want:
It depends on using file.For example for reading text file, any movement is needed. You can read it from asset directory.
But if you want to write in a text file, you must move it to internal/external memory in a directory you have set in your code.
In my Android SDK folder on Windows I have found anim folder with lot of different .xml files, but in my application in eclipse when I try to load one it only shows me few of them. How can I access those rest without creating custom XML file and pasting the code into it? I mean can I access them like R.anim.file.xml ?
Yes. There is an R.class file precompiled and given for you by the Android SDK. You can simply refer to it by android.R.anim.slid_in, android.R.anim.slide_out etc.
Find more out about it here: http://developer.android.com/reference/android/R.anim.html
I am trying to design a new Android application.
For that application I will have an XML file that will be located somewhere on the server. This file will be generated from the mySQL DB.
For now (developmental phase) I got a simple and small XML file that I need to put in the Android Eclipse project in order to read it and present the data on the phone.
I just tried to put this file in res/values, but compiler gives me an error: "Invalid start tag".
Looking through the stackoverflow and google I see a lot of different answers and google even give me an answer of how to parse xml file on Android. ;-)
So is there a "standard" place where such XML file goes in Android Eclipse project? Think about it as the data that is read from the DB.
Some answers are to place it in the res/xml folder. I just made a brand new Android project and I don't see such folder in it. Do I create one? Shouldn't it be done automatically?
Some says you need to put it the res/raw folder. Again it is not present in the Eclipse project. Do I make one? Shouldn't it be present already?
Please clarify.
Shouldn't it be present already?
It doesn't have to. There can be thousands of folders inside res/ folder. You don't want to have them all at first.
Do I make one?
Yes. Add folders when you need them.
Some answers are to place it in the res/xml folder.
Some says you need to put it the res/raw folder.
The difference between these folders is that files inside raw stay the same you put them and inside xml are parsed when APK is created and put there in a binary, optimized form, similar to what happens to layouts, AndroidManifest and other.
This question already has answers here:
Can the Android layout folder contain subfolders?
(20 answers)
Closed 9 years ago.
Of course I can right click the raw folder and add new folder but when I export the project, the APK file does not contain the new sub folder.
You can't.
The folders in /res/ have a predefined structure, and you can't add subfolders.
However, seeing as this is the raw folder, you may want to look into using the assets folder, in which sub folders are supported.
Keep in mind thought that by using assets you won't be able to use R.*.* references anymore. You will have to go through the AssetManager.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
how we can remove a file from the assets folder at runtime in android?
Is it possible to create a file in assets folder when an application is run and delete the same file when the app is stopped.
For asset you have read file permission only. So you cannot create / delete files in assets folder. Following are the restrictions applied to assets folder.
1) Only Read Permission available for this folder.
2) File size for placing inside the assets limit to 10 MB.If you want to place
then the larger file should be placed as chunk.
3) You can use this folder, for placing files like database file, font file etc...
Don't fight with it. It is not a proper way of dealing with files using assets folder.
You can use SDcard that is suitable location for creating and deleting files
You can use standard method for placing files in SDcard through app,
Environment.getExternalStoragePublicDirectory("filetype");
The apk is read only and the assets/ folder is not modifiable at runtime, which sounds like something you may be seeking. Check this question