Accessing resources from the Android General Class?

Asked 2 years ago, Updated 2 years ago, 18 views

Util, a function that is often used in development.Create a java class.

I'm using it as a static function.

This Util.I need to refer to the contents of strings.xml in the java class.

I don't know how to do it

Is there a way to access resources in a regular class (not an activity)?

Thank you

android

2022-09-21 20:00

1 Answers

The context is required to access the resource. Therefore, you can receive context as a parameter in the method and process it.

public static void test (Context) {
    //do some thing
}


2022-09-21 20:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.