-2
public static Toast makeText( Context context, int resId, int duration)

As in above code, Context is needed to make a Toast. Explanation given by various resources is that Context is needed by the Toast class to be able to find and use the string’s resource ID. I am not able to understand why it is so. How does Context help in finding resource?

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
Mandroid
  • 6,200
  • 12
  • 64
  • 134

2 Answers2

2

To answer this part of the question

How does Context help in finding resource ?

From the context documentation, context exists to access application specific resources

Interface to global information about an application environment. ... It allows access to application-specific resources and classes,...

So the context class contains a method getResource() which

Return a Resources instance for your application's package.

ThomasThiebaud
  • 11,331
  • 6
  • 54
  • 77
  • Thanks to all for responses. So what I understand now is that every application has its own context which in turn is ONLY doorway to resources of that particular application. And there is no other way to access application's resources. – Mandroid Nov 10 '15 at 08:58
0

The resource ids are context specific. Different applications have different contexts which means they may lead to different resources.

Simas
  • 43,548
  • 10
  • 88
  • 116