Alex Rivera | Logout

Android: getString(R.string) in static method

Asked 2010-09-29T14:43:24.353
30

When programming for Android sometimes you have to use static methods. But when you try to access you resources in a static method with getString(R.string.text) you'll get an error. Making it static doesn't work.

Does anyone knows a good way around this? The resource files in Android are very helpful for creating things in different languages or making changes to a text.

Edit
Report

1 Answer

31

One way or another, you'll need a Context for that... For static methods this probably means you need to pass along a Context when calling them.

answered 2010-09-29T14:45:37.080

Your Answer