2025-05-17 14:25:38 +00:00
|
|
|
import io.appwrite.Client;
|
|
|
|
|
import io.appwrite.coroutines.CoroutineCallback;
|
|
|
|
|
import io.appwrite.services.Databases;
|
|
|
|
|
|
|
|
|
|
Client client = new Client(context)
|
|
|
|
|
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
2025-07-23 15:26:20 +00:00
|
|
|
.setAdmin("") //
|
2025-05-17 14:25:38 +00:00
|
|
|
.setSession("") // The user session to authenticate with
|
|
|
|
|
.setKey("") //
|
|
|
|
|
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
|
|
|
|
|
|
|
|
|
|
Databases databases = new Databases(client);
|
|
|
|
|
|
|
|
|
|
databases.createDocument(
|
|
|
|
|
"<DATABASE_ID>", // databaseId
|
|
|
|
|
"<COLLECTION_ID>", // collectionId
|
|
|
|
|
"<DOCUMENT_ID>", // documentId
|
|
|
|
|
mapOf( "a" to "b" ), // data
|
|
|
|
|
listOf("read("any")"), // permissions (optional)
|
|
|
|
|
new CoroutineCallback<>((result, error) -> {
|
|
|
|
|
if (error != null) {
|
|
|
|
|
error.printStackTrace();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d("Appwrite", result.toString());
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|