• Post Reply Bookmark Topic Watch Topic
  • New Topic

A sentence about usefulness of Resources  RSS feed

Ranch Hand
Posts: 36
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In "Hello Android" book that i am reading , there is a sentence about usefulness of Resources that i can't understand .
Please give me some help about it .
The paragraph is :

"The resource compiler compresses and packs your resources and then
generates a class named R that contains identifiers you use to reference
those resources in your program. This is a little different from standard
Java resources, which are referenced by key strings. Doing it this way
allows Android to make sure all your references are valid and saves
space by not having to store all those resource keys
. Eclipse uses a
similar method to store and reference the resources in Eclipse plug-ins."

The underlined sentence has two part .

I understand part one in this way :
When there is some error in for example XML lay out files in Android project in Eclipse IDE ,
The IDE does not work correctly and some red signs are appeared next to files that have
error in left side project browser of Eclipse.

Is the thing that i understood is correct and complete ???

And about part two .
I cant understand it . What it says ??

Thanks for your help
Posts: 42975
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, part 1 is about checking the correctness of resources at compile time, or -in the case of IDEs such as Eclipse- even earlier than that.

Part 2 says that at runtime resources are referenced by integers. If you've seen such an R.java file you'll notice it's essentially just a list of all resources, each one identified by a unique int. An int takes up a lot less storage space than most strings - which is what you'd use in desktop or server Java code to identify resources (e.g. as keys in Properties files). Storage space is more at a premium in mobile platforms, so anything that reduces it is welcome.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!