Back

[CLOSED] How do I maintain only one instance of the client and reuse it across my app?

  • 0
  • Android
  • Accounts
Aman
31 May, 2023, 21:46

I am creating an Android application using Android studio. Programming language Java.

TL;DR
The user wants to maintain only one instance of the client and reuse it across their app. They are unsure if Java has late initialization. They are considering creating a singleton but are confused because the client requires context. Another user suggests creating a singleton or a global object or attaching the client to the Application. It is mentioned that this isn't specific to appwrite and the user is developing an Android application using Java in Android Studio.
Drake
31 May, 2023, 23:50

This isn't really an appwrite specific thing...perhaps you can create a singleton or a global object or attach the client to the Application. I don't know much about android development, though

Aman
1 Jun, 2023, 00:03

I can create a singleton but the client requires context that's why I am confused.

Drake
1 Jun, 2023, 00:05

late initialization, then?

Aman
1 Jun, 2023, 00:07

That is to say I should create only client instance the initialise it whenever I need it in activity

Aman
1 Jun, 2023, 00:10

Thanks that was helpful.

joeyouss
1 Jun, 2023, 05:28

[CLOSED] How do I maintain only one instance of the client and reuse it across my app?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more