Skip to content

Commit ca3b333

Browse files
committed
Add Java example for accessing application context
Updated README.md to include a Java example for accessing the application context using `ContextProvider.getContext()`. This complements the existing Kotlin example and provides clarity for Java developers.
1 parent a5a2cc9 commit ca3b333

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ implementation("io.github.kdroidfilter:androidcontextprovider:1.0.1")
2929

3030
2. **Getting the Context**
3131

32-
You can access the application context (not an activity context) from anywhere in your app like this:
33-
32+
You can access the application context (not an activity context) from anywhere in your app like this:
3433
```kotlin
3534
val context = ContextProvider.getContext()
3635
// Use the context as needed
3736
```
38-
37+
or in Java :
38+
```java
39+
Context context = ContextProvider.getContext();
40+
// Use the context as needed
41+
```
3942
### Important Notes
4043

4144
- **Automatic Initialization**: The `ContextProvider` is initialized automatically via `ContentProvider`, eliminating the need for manual setup.

0 commit comments

Comments
 (0)