Can anyone tell me what is the difference between String
and string
in Android?
Asked
Active
Viewed 1,960 times
-9

Tom van Enckevort
- 4,170
- 1
- 25
- 40

Kannan_SJD
- 1,022
- 2
- 13
- 32
-
2Do you mean `java.lang.String` and `R.string`? – Evos Jan 25 '13 at 11:16
-
what is the question? and upvotes? – Mohammed Azharuddin Shaikh Jan 25 '13 at 11:18
-
If you are talking about String class then refer this http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string – Mac Jan 25 '13 at 11:19
-
please ask with the exact package names, else we are just guessing what you mean – Thrakbad Jan 25 '13 at 11:19
-
you should give (and look at it, and, while you're at it, read the doc related to it) the fully qualified name (with package and everything) – njzk2 Jan 25 '13 at 11:55
4 Answers
6
String is a class which is present in library java.lang.String, whereas string is an xml file
present in values in android where you will refer id with values in which you will retrieve
in coding.

Shadow
- 6,864
- 6
- 44
- 93
2
string refers to string(sub class) inside R class in your Project.
String refers to java.lang.String package

Gugan
- 1,625
- 2
- 27
- 65
2
I believe you are asking about java.lang.String and android.R.string.
String
class is defined in package java.lang
which is automatically imported to your android project (infact all java project).
string is android.R.string
, which is static string's given in xml.

Krishnabhadra
- 34,169
- 30
- 118
- 167
2
Check out these links
For Example look at the code below
String name = "";
switch (row.getNameKey()) {
case keyName1:
name = getString(R.string.keyName1);
break;
case keyName2:
name = ...
...
}
R.string is used to getString from Resources (Strings.xml)...

Vaibs_Cool
- 6,126
- 5
- 28
- 61