Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:29:22+00:00 2026-06-01T08:29:22+00:00

In android R.java is used to provide access to resources defined in XML files.

  • 0

In android R.java is used to provide access to resources defined in XML files.
To access the resource we need to invoke findViewById() method passing in the id of the resource to be fetched.

This is similar to Spring where beans are defined in a XML context and are fetched by using application context. context.getBean("beanId")

This provides loose coupling since the beans are defined externally and could be changed without making modifications to the code.

This has me confused. Though what Android does looks similar to spring, what advantage does it offer?

  1. What is the point of having an intermediate R.java anyway? Couldn’t we just acquire resources directly from XML by use of a resource
    reader/application context. e.g. findViewById("resourceId")
  2. There isn’t any loose coupling. Since references in R.java get auto-generated how could one delete a resource and put in a new one?
  3. What design pattern does it follow(if there is one)?
  4. Wouldn’t it be better to have resources injected using IOC (like Roboguice)? Why did then google decide to give us such
    a wierd way of working with resources?

Pardon my ignorance. I’m a newbie Java developer trying too many things at once. 🙂
Thanks for all the feedback.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:29:24+00:00Added an answer on June 1, 2026 at 8:29 am

    android.R.java is not just where XML ids are stored. It also contains access to resources – such as drawables, layouts, strings, arrays, and basically anything you can declare in resources.

    Personally I find that it is useful when using Eclipse. I can simply type findViewById(R.id. and Eclipse will show a tooltip with a list of options to choose from.

    However at a platform level, I would say that the hardcoded id variables help prevent errors when using Strings to identify resources — something that can be debuggable while programming (or during compilation, rather than runtime).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm familiar with C++ but never used Java. I've just started learning Android development.
I am porting an app from Android Java to iPhone. In Android I used
How diferent is Java used in Android apps development from Java used to develop
Ola, Android/JAVA question, I need to test if a object is not NULL and
I am using android java to create an application that uses the accelerometer, i
I am a little new to android/java. I am trying to pass JSON values
as someone's who's just starting to get into Android/Java programming, I've read the docs
I am a beginner when it comes to programming with Android/Java, and I am
I already know quite a few tricks with Android java and I have an
First, I'd like to let you know my experience. PHP - medium | Android/Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.