Hi all,
How to iterate the keys in a Resource fie (.rrc) in a loop & how do I get the length or the no. of elements in the resource file, I mean the end of the file ?
Hi all,
How to iterate the keys in a Resource fie (.rrc) in a loop & how do I get the length or the no. of elements in the resource file, I mean the end of the file ?
Since it isn't an order list of resources on the implementation side, there really isn't a way to do exactly what you are asking. However, you could put all your elements into an array within the resource and then easily work with those resources in the code like you would work with any other array. Here's the syntax for declaring an array within a resource file:
RESOURCE_ARRAY#0={
"HEY THERE",
"WHAZZUP!",
"NICE ARRAY OF STRINGS YOU GOT THERE",
"THANKS, I WORKOUT",
"IT SHOWS!",
};
Thanks but I m using Blackberry API's where I m accessing the Resource file as,
ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
Now I want to iterate through it using for() & want to get its key's.
So how to achieve it?
I'm not sure why you would want to iterate through resources. You may, however, define arrays as resources, then iterate through the array which is pulled as a single resource.
I want to iterate through Resource file as at Run-time I m getting a String which I want to compare with all the Resource KEYs & if the String which I got matches with any of the KEY then its corresponding VALUE is fetched using ,
currentValue = _resources.getString(KEY);
So I m trying to iterate through it using
for(int i=0; i< (get Resource total Length); i++)
{
key = (get Resource KEY)
if(string.equals(key))
currentValue = _resources.getString(key);
}
but I m not getting "how to get Resource total length (no of elements in Resource file) & its KEY".
any solution for these issues ?