getResources()用在有context的地方,没有context的地方和静态类中是不能用的(也有开发者通过一些方式对context进行封装用在静态类中),而且getResources()只能用于获取应用本身的资源
Resources.getSystem() 可以在任何地方进行使用,但是有一个局限,只能获取系统本身的资源
The difference is not only in what you get, but in WHERE can you use them.
The first and the third ones are using "context." invisibly. So, very often (in static members or out of activity members) you can't use them directly, unless you pass context or resource as a static variable or as a parameter into your scope. But the second one
Resources.getSystem().getString(android.R.string.cancel)
You can use ABSOLUTELY EVERYWHERE in your application, even in static constants declaration! But for system resources only
网友评论