I have some sql queries that I would like to put in a .txt file and import to my application on start up. 2 questions:
1) Where is the best place to put these files?
2) I thought maybe I can put them in /res/raw/sql/ but the files don't come up with AutoComplete. (They come up if I put them in /res/raw/). Any ideas?
You cannot make sub folders of the resources folder Android provides per default. The same is true for the various layout folders etc. So you have to put them directly in /res/raw. But anyway, I think there it is the best place to save them.
Related
In my androidTest/resources directory I have a few hundreds of images. I want to read all of them in a loop and test against specific function. I don't want to use their names, as often I don't know them. Is there any possibility to load by regex or iterate through the directory?
I found a solution. Change the name of directory from resources to assets and then use InstrumentationRegistry.getInstrumentation().context.resources.assets.list("")
According to this thread, in order to make Hebrew available on all devices, I need to maintain two similar files of each resource type, one in values-iw and another in values-he. Having a ready-to-use strings.xml, I was wondering if there's a way to "link" the files in one of these folders to the files in the second folder instead of making an alias for each string (exampled here).
Thanks!
I am currently developing an Android version of a pre-existing iOS application.
I have the original resource folder with all the drawable files (200+ .png files).
The person who wrote the iOS named every single .png file like this: "examplePngName.png"
is there anyway I can allow the res drawable folders to allow capitals or a better way than manually renaming over 200 files..?
Search the web and download a Bulk Rename Utility for your OS.
For example BulkRenameUtility (Note: this one purports to handle case changes as you require, but I haven't tried it myself. It was just the first one on the list in a quick google search!).
I'd like the ability to "overwrite" the Android resources packaged within my apk by having the app periodically download a zipped file containing overrides that follow the same naming convention as the source does. For example, the zip might consist of the following paths:
res/values/strings.json
res/values-land/strings.json
My code would parse those files and produce a Map> that would map the string resource id to a folder->value pair (or something along these lines). At this point I'm really only concerned with strings and images (maybe arrays), but not layouts, etc.
To the point: Is there any method available, that, given a list of folder names, would tell me which one the Android resolver would choose based on current state? I'm assuming this is difficult because the compiler breaks everything down to ids, but figured it was worth a shot. Any ideas?
Is there any method available, that, given a list of folder names, would tell me which one the Android resolver would choose based on current state?
No. You are welcome to roll this yourself based on Configuration, DeviceMetrics, and kin. You will also need to create your own parsers for your own files, as Android's resource system only works with resources, not arbitrary files retrieved from arbitrary locations.
The expectation in Android is that if you want to update resources, you update the app, probably because there were also code changes as well. Admittedly, this approach has its limitations.
I have an app on the iPhone and need to port it to android. For this I would like to group screen related files like classes and xml per screen in one "screen group" per screen somehow, ideally also strings and other value files
if I use folders I can only group res files separately and src files separately.
what would be the best way?
Thanks very much!
EDIT:
If that should not be possible, how to best then solve this issue? Do you create a subfolder in the src and another in the res for each screen?
The way you group files for the iphone is not possible for an android project. Android has pre determined folders which hold specific files, if you break this structure, your building process will fail. Its not ideal but that just how it it.
When it comes to source java files, they follow the concept of packages which are basically folders. The 'src' folder is the part where you can create sub folders as you desire. If you are adamant about keeping the files related to a screen in one place, you should create the layouts with java code and not use layout xml files.
But using xml layout files make development much easier and faster. Consider that as the presentation and java files as the logic+data. So group java files as you want and leave xml files in the layout folder with easy to identify names.
android uses certain directory layout for project structures (i.e. convention over configuration). Basically you will want to put your XML layout files in res/layout directory. Please read http://developer.android.com/guide/developing/projects/index.html#ApplicationProjects for further information.
Unfortunately, there's no easy way to do this in Eclipse. You can't create custom directories in your Android app's /res directory, you can only use permitted dir-names. E.g. you can't have a /res/layout-myscreen1 and /res/layout-myscreen2. You also must put your resources in /res, and your code files in packages, so they're at separate places in your project.
You can use Working Sets to group related files together however, but they're quite painful to use IMHO. Check the eclipse docs and tutorials out on them.