Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use the string ID android.R.string.share?

It's right there in values/strings.xml in Android's source - why isn't it in android.R?

edit: I am referring to Android's built in string resources (android.R.string.…) and not my own project's resources - so, for example, while I can use android.R.string.cancel, I can't use android.R.string.share despite the fact that the two of them are declared in the same file in Android's source code

like image 228
Daniel Avatar asked Jan 23 '26 23:01

Daniel


1 Answers

They are just resources under the resource folder.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="share">hello</string>
</resources>

The above resource has a entry in R.java file which in under your package name. You can open R.java and have a look at it.

    public static final int share=0x7f040000;

You can refer to the string in Strings.xml as

  R.String.share

The R.strin.share is an int.

You can also get the string as

   String s= getResources().getString(R.string.share);

Edit:

http://developer.android.com/guide/topics/resources/accessing-resources.html#PlatformResources.

Check the topic in the above link under the heading Accessing Platform Resources

Android contains a number of standard resources, such as styles, themes, and layouts. To access these resource, qualify your resource reference with the android package name.

For list of all resources check the link

http://developer.android.com/reference/android/R.html

The list from http://developer.android.com/reference/android/R.string.html

enter image description here

like image 180
Raghunandan Avatar answered Jan 26 '26 15:01

Raghunandan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!