appwrite/docs/examples/1.8.x/client-android/java/tablesdb/create-row.md

38 lines
1 KiB
Markdown
Raw Normal View History

```java
2025-08-20 07:22:48 +00:00
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.Permission;
import io.appwrite.Role;
import io.appwrite.services.TablesDB;
2025-08-20 07:22:48 +00:00
Client client = new Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
2025-08-23 10:52:20 +00:00
TablesDB tablesDB = new TablesDB(client);
2025-08-20 07:22:48 +00:00
2025-08-20 14:20:05 +00:00
tablesDB.createRow(
2025-08-20 07:22:48 +00:00
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<ROW_ID>", // rowId
Map.of(
"username", "walter.obrien",
"email", "walter.obrien@example.com",
"fullName", "Walter O'Brien",
"age", 30,
"isAdmin", false
2025-09-05 12:00:39 +00:00
), // data
List.of(Permission.read(Role.any())), // permissions (optional)
2025-10-09 08:04:50 +00:00
"<TRANSACTION_ID>", // transactionId (optional)
2025-08-20 07:22:48 +00:00
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
})
);
```