forked from Gautham495/react-native-nitro-cloud-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContextProvider.kt
More file actions
48 lines (39 loc) · 1.32 KB
/
ContextProvider.kt
File metadata and controls
48 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.margelo.nitro.nitroclouduploader
import android.content.ContentProvider
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.net.Uri
/**
* ContentProvider to automatically get application context on app startup
* This is called before any Activity or Application.onCreate()
*/
class ContextProvider : ContentProvider() {
override fun onCreate(): Boolean {
// Store application context globally
appContext = context?.applicationContext
println("✅ ContextProvider initialized with context: ${appContext != null}")
return true
}
override fun query(
uri: Uri,
projection: Array<out String>?,
selection: String?,
selectionArgs: Array<out String>?,
sortOrder: String?
): Cursor? = null
override fun getType(uri: Uri): String? = null
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0
override fun update(
uri: Uri,
values: ContentValues?,
selection: String?,
selectionArgs: Array<out String>?
): Int = 0
companion object {
@Volatile
var appContext: Context? = null
private set
}
}