I am following the documentation on Firebase website on setting up an Java Admin SDK. So I add the dependency to the build.gradle, and added the following code:
ApiFuture api=/*your reference to database*/usersRef.setValueAsync(users/*the data*/);
Object o = api.get(/*time out*/8,TimeUnit.SECONDS/*unite for time out her is seconds*/);