I recently added a feature to send images too along with the option to send text messages. Everything was working fine before that - messages popped as expected queried by descending time. But after I added this image sending feature whenever I scroll up or down the chat the messages get all jumbled up and I don't know why.
When I send only text:
Before Scrolling https://i.stack.imgur.com/2NMVHl.jpg
After Scrolling https://i.stack.imgur.com/2Nxpc.jpg (same)
When I send Image with text
Before Scrolling https://i.stack.imgur.com/rS6Mx.jpg
After Scrolling https://i.stack.imgur.com/OP5DK.jpg
In my code there are two places from where message(image or text) can be uploaded.
For sending Image message:
Briefings - Here I upload the image to the Storage and then retrieve its URL. Then I store the URL to firestore in form of string (which I later use to download the image using Picasso) along with other message details.
final Long currentTime = System.currentTimeMillis();
final String time = currentTime + "";
final StorageReference fileref = storageReference.child("Image Messages")
.child(uid + time);
StorageTask uploadTask = fileref.putFile(uri);
uploadTask.continueWithTask(new Continuation() {
#Override
public Object then(#NonNull Task task) throws Exception {
if(!task.isSuccessful()){
throw task.getException();
}
return fileref.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
#Override
public void onComplete(#NonNull Task<Uri> task) {
if(task.isSuccessful()){
Uri downloadUrl = task.getResult();
String myUrl = downloadUrl.toString();
Map<String, Object> chat = new HashMap<>();
chat.put("message", myUrl);
chat.put("time", currentTime);
chat.put("sender", mUser.getUid());
chat.put("groupId",Gid);
chat.put("type","image");
chat.put("username",preferences.getData("username"));
chat.put("name",preferences.getData("usernameAdded"));
firestore.collection("aGroups").document(Gid).collection("Chat")
.add(chat).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
#Override
public void onSuccess(DocumentReference documentReference) {
showChatMessages();
dialog.dismiss();
Toast.makeText(getApplicationContext(),"Message Sent", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(getApplicationContext(),"Error", Toast.LENGTH_SHORT).show();
}
});
}
}
});
For sending text message
Briefings - Here I upload the message and it's details
Map<String, Object> chat = new HashMap<>();
chat.put("message", message.getText().toString());
chat.put("time", System.currentTimeMillis());
chat.put("sender", mUser.getUid());
chat.put("groupId",Gid);
chat.put("type","text");
chat.put("username",preferences.getData("username"));
chat.put("name",preferences.getData("usernameAdded"));
firestore.collection("aGroups").document(Gid).collection("Chat")
.add(chat).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
#Override
public void onSuccess(DocumentReference documentReference) {
Toast.makeText(ChatInterface.this, "Message Sent", Toast.LENGTH_SHORT).show();
showChatMessages();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(getApplicationContext(),"Error", Toast.LENGTH_SHORT).show();
}
});
This is where I add callbacks
private void showChatMessages() {
firestore.collection("aGroups").document(Gid).collection("Chat")
.orderBy("time", Query.Direction.DESCENDING)
.addSnapshotListener(new EventListener<QuerySnapshot>() {
#Override
public void onEvent(#Nullable QuerySnapshot value, #Nullable FirebaseFirestoreException error) {
if(error != null){
Log.d("Check", "listen failed: " + error.getMessage());
}
else{
Log.d("Check", "Snapshot worked");
List<ChatModel> list = new ArrayList<>();
list.clear();
for(QueryDocumentSnapshot query : value){
list.add(new ChatModel(
query.getString("groupId")
, query.getId()
, query.getString("message")
, query.getString("sender")
, query.getLong("time")
, query.getString("name")
, query.getString("username")
, query.getString("type")
));
}
recycler_interface.setAdapter(new RealChatRecyclerInterface(mUser.getUid(),list));
}}
});
}
I am adding my whole RealChatRecyclerInterface in this pastebin link.
Use holder.setIsRecyclable(false); in your RealChatRecyclerInterface
Related
İ'm developing chat app with android studio / java and using firebase , i'm getting an error while getting server timestamps.
MY SEND FUNCTİON
public void send(View v) {
if (!status) {
String message = text.getText().toString();
String senderUID = firebaseAuth.getCurrentUser().getUid();
HashMap<String, Object> postData = new HashMap<>();
postData.put("senderID", senderUID);
postData.put("time",FieldValue.serverTimestamp());
postData.put("message", message);
firebaseFirestore.collection("chats").document(id).collection("messages").document()
.set(postData)
.addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
text.setText("");
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(chat.this, "Sunucu Hatası...", Toast.LENGTH_LONG).show();
finish();
}
});
}
}
MY GET FUNCTİON
public void dataRead(String id) {
CollectionReference docRef = firebaseFirestore.collection("chats").document(id).collection("messages");
docRef.orderBy("time", Query.Direction.DESCENDING)
.addSnapshotListener(new EventListener<QuerySnapshot>() {
#Override
public void onEvent(#Nullable QuerySnapshot queryDocumentSnapshots, #Nullable FirebaseFirestoreException e) {
if (e != null) {
System.err.println("Listen failed: " + e);
return;
}
if (queryDocumentSnapshots != null) {
messageFb.clear();
dateFb.clear();
dateFb.clear();
for (DocumentSnapshot snapshot : queryDocumentSnapshots.getDocuments()) {
Map<String, Object> data = snapshot.getData();
String message = (String) data.get("message");
String sender = (String) data.get("senderID");
Timestamp timestamp = (Timestamp) data.get("time");
messageFb.add(message);
senderFb.add(sender);
dateFb.add(timestamp.toDate().toString().substring(11,16)); //ERROR İS HERE
chatRecycler.notifyDataSetChanged();
}
}
}
});
}
THERE İS THE SMAPLE ERROR java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Date com.google.firebase.Timestamp.toDate()' on a null object reference
When i send a any message in my app , the app is crashing , but when i open again , everythings works fine , just crashing when i send and get new data. ANY İDEAS ?
I have uploaded 1 Hashmap to firestore.And when i try to upload one more Hashmap to the same document it replaces my previous Hashmap.Why is it so?
I change the String title everytime and still it replaces the previous Hashmap.
String poll1 = Poll1.getText().toString().trim();
String poll2 = Poll2.getText().toString().trim();
String poll3 = Poll3.getText().toString().trim();
String title = Title.getText().toString().trim();
DocumentReference documentReference = firestore.collection("Polls").document("abc1");
Map<String, Object> nestedData = new HashMap<>();
nestedData.put(poll1 , 0 );
nestedData.put(poll2 , 0);
nestedData.put(poll3 , 0);
Map<String, Object> upload = new HashMap<>();
upload.put(title, nestedData);
documentReference.set(upload).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(polls.this, "UPLOADED", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(polls.this, "FAILED", Toast.LENGTH_LONG).show();
}
});
your document needs to mention that this has to be merged instead replace.
.set(data, SetOptions.merge())
Try this if it works.
documentReference.set(upload, SetOptions.merge()).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(polls.this, "UPLOADED", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(polls.this, "FAILED", Toast.LENGTH_LONG).show();
}
});
I am new to android development and I have an issue.
I have a fragment in which a user can post an announcement and should be able to upload a photo(optional).
When the form is full and the "Post announcement" button is pressed, I trigger the method to save the information to the database.
The only problem I am facing is retrieving the Uri of the newly uploaded photo.
This is the code which extracts the information.
public Map<String, Object> appendDataFromAnnouncementForm(){
String title = titleLineEdit.getText().toString();
String category = categoryLineEdit.getText().toString();
String description = descriptionLineEdit.getText().toString();
String date = dateLineEdit.getText().toString();
String time = timeLineEdit.getText().toString();
String location = locationLineEdit.getText().toString();
//Image upload to firebase + getting the Uri
if(localPhotoUri != null){
uploadImageToFirebase(generatePhotoName(localPhotoUri), localPhotoUri);
}
Map<String, Object> newAnnouncement = new HashMap<>();
//#####################################################
if(uploadedImageUri != null) // <- this is always null
{newAnnouncement.put("imageUri", uploadedImageUri.toString());}
//#############################################################
newAnnouncement.put("title", title);
newAnnouncement.put("category", category);
newAnnouncement.put("description", description);
newAnnouncement.put("date", date);
newAnnouncement.put("time", time);
newAnnouncement.put("location", location);
return newAnnouncement;
}
Below I am posting the code which uploads the photo to Firebase Storage. Since
private void uploadImageToFirebase(String photoName, Uri localContentUri) {
imagesStorageReferance = myStorageReference.child("images/" + photoName);
imagesStorageReferance.putFile(localContentUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
#Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//getUploadedImageUri(referenceToImageFolder);
imagesStorageReferance.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
#Override
public void onSuccess(Uri uri) {
Log.d(TAG, "onSuccess: The download url of the photo is "
+ uri.toString());
uploadedImageUri = uri; /// <- I want to retrieve this
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.d(TAG, "onFailure: Failed uploading the photo to the database " + e.getMessage());
}
});
}
From what I have read on the Internet, this is an synchronization problem(basically, the app registers the information to the database before my photo is uploaded). There are many solutions which I have tried, but I can't really figure it out one to work on my case...
I would be very grateful if you could provide me some explanation on what I should do in order to fix this. How can I wait the photo to be uploaded ?
I am sharing the code from my project:
Assign this globally:
StorageTask uploadTask;
String myUrl = "";
and this is code:
private void uploadImage()
{
if (imageUri != null)
{
final StorageReference reference = storageReference.child(System.currentTimeMillis()+"."+getExtension(imageUri));
uploadTask = reference.putFile(imageUri);
uploadTask.continueWithTask(new Continuation() {
#Override
public Object then(#NonNull Task task) throws Exception {
if (!task.isComplete())
{
throw task.getException();
}
return reference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
#Override
public void onComplete(#NonNull Task<Uri> task) {
if (task.isSuccessful())
{
Uri downloadUri = task.getResult();
myUrl = downloadUri.toString();
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("Categories")
.child(randomKey);
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("categoryId", randomKey);
hashMap.put("categoryImage", myUrl);
hashMap.put("categoryName", editText.getText().toString());
databaseReference.setValue(hashMap);
save.setVisibility(View.VISIBLE);
startActivity(new Intent(AddCategoryActivity.this, CategoriesActivity.class));
}
else
{
save.setVisibility(View.VISIBLE);
Toast.makeText(AddCategoryActivity.this, "Failed!", Toast.LENGTH_SHORT).show();
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
save.setVisibility(View.VISIBLE);
Toast.makeText(AddCategoryActivity.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
else
{
save.setVisibility(View.VISIBLE);
Toast.makeText(this, "No Image Selected", Toast.LENGTH_SHORT).show();
}
}
Since firebase works asynchronously, the code continues to execute regardless of whether firebase has finished the upload process or not. In your case, the time to run the code following firebase is faster than the upload time to firebase to eventually assign uploadedImageUri = uri; which explains why you are getting a null value for uploadedImageUri present directly after the call for upload.
For this matter, I would suggest you to register to database inside uploadImageToFirebase function after uploadedImageUri = uri; to ensure that uploadedImageUri is never null and always fetched before database registration.
private void uploadImageToFirebase(String photoName, Uri localContentUri) {
imagesStorageReferance = myStorageReference.child("images/" + photoName);
imagesStorageReferance.putFile(localContentUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
#Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//getUploadedImageUri(referenceToImageFolder);
imagesStorageReferance.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
#Override
public void onSuccess(Uri uri) {
Log.d(TAG, "onSuccess: The download url of the photo is "
+ uri.toString());
uploadedImageUri = uri;
String title = titleLineEdit.getText().toString();
String category = categoryLineEdit.getText().toString();
String description = descriptionLineEdit.getText().toString();
String date = dateLineEdit.getText().toString();
String time = timeLineEdit.getText().toString();
String location = locationLineEdit.getText().toString();
Map<String, Object> newAnnouncement = new HashMap<>();
newAnnouncement.put("imageUri", uploadedImageUri.toString());
newAnnouncement.put("title", title);
newAnnouncement.put("category", category);
newAnnouncement.put("description", description);
newAnnouncement.put("date", date);
newAnnouncement.put("time", time);
newAnnouncement.put("location", location);
//UPLOAD newAnouncement TO FIREBASE HERE...
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.d(TAG, "onFailure: Failed uploading the photo to the database " + e.getMessage());
}
});
}
programmers, I am very new to android studio and java, in this case, I am trying to upload retrieved user info and store them in firebase database. the retrieve process is successful, and the retrieve URL can be seen after logged. However, the String pathToProfile is not assigned with the URL, when I checked the log, it is null. Thanks in advance!
Global declaration:
String pathToProfile;
Map<String, Object> UserInfo = new HashMap<>();
Function to retrieve the download URL
// retrieved URL should be saved in user document
private void retrieveProfileViaURL () {
profileRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
#Override
public void onSuccess(Uri uri) {
pathToProfile = uri.toString();
UserInfo.put(PROFILE_URL, pathToProfile);
Log.d(TAG, "retrieve profile image successful" + pathToProfile);
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception exception) {
Log.d(TAG, "retrieve profile image failure");
// pathToProfile = "uri download unsuccessful";
}
});
}
Function to upload userinformation to firebase
private void uploadUserInfo(String user, String bioInfo) {
// CollectionReference users = db.collection("users");
String UID = getUserID();
retrieveProfileViaURL();
// UserInfo.put(USERID, UID);
UserInfo.put(USERNAME, user);
UserInfo.put(BIO, bioInfo);
mDocRef.collection("users").document(UID).set(UserInfo)
.addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Log.d(USER_INFO, "Document has been saved");
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.w(USER_INFO, "Document was not saved!", e);
}
});
}
All data from the Firebase Database is read asynchronously. You can not get values outside the call. That's why your pathToProfile shows null.
For Better approach you can try something like this.
After the user upload the data it will automatically allow user to write in data with url
private void retrieveProfileViaURL () {
profileRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
#Override
public void onSuccess(Uri uri) {
pathToProfile = uri.toString();
String UID = getUserID();
UserInfo.put(USERNAME, user);
UserInfo.put(BIO, bioInfo);
UserInfo.put(PROFILE_URL, pathToProfile);
mDocRef.collection("users").document(UID).set(UserInfo)
.addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Log.d(USER_INFO, "Document has been saved");
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.w(USER_INFO, "Document was not saved!", e);
}
});
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception exception) {
Log.d(TAG, "retrieve profile image failure");
// pathToProfile = "uri download unsuccessful";
}
});
}
I'm trying to upload some images to firestore storage and put the image URL to firebase database. The images are uploading successfully but the image URLs aren't being added to the database. The problem that I think might be causing this is that the image URL is being added to the Hashmap after uploading the image but the database upload process isn't waiting for the URL instead, adding all other HashMap keys to the database before the Upload task returns the URL. This way all other keys get added to the database but not the Image URLs. In the below code product id is being added successfully to the database, also if I leave any image unselected its url alse gets added as empty to the database which is working fine but if I select an image to upload, The hashmap to database upload finishes even before getting the uploaded image URL.
public class AddProductDataActivity extends AppCompatActivity {
String productId;
EditText productIdEditText;
ImageView addProductImage3;
Button addProductSubmit;
final int IMAGE3_REQUEST = 30;
Uri image3LocationPath;
StorageReference objectStorageReference;
FirebaseFirestore objectFireBaseFireStore;
Map<String, String> objectMap = new HashMap<>();
StorageReference img3Store;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_product_data);
brandNameEditText =(EditText)
addProductImage3 = (ImageView) findViewById(R.id.add_product_image3);
objectStorageReference =
FirebaseStorage.getInstance().getReference("images");
objectFireBaseFireStore = FirebaseFirestore.getInstance();
addProductImage3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent objectIntent = new Intent();
objectIntent.setType("image/*");
objectIntent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(objectIntent, IMAGE3_REQUEST);
}
});
addProductSubmit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
productId = productIdEditText.getText().toString();
if(image3LocationPath != null)
{
final String image3Name = productId + "_image3." + getExtension(image3LocationPath);
img3Store = objectStorageReference.child(image3Name);
UploadTask imageUploadTask = img3Store.putFile(image3LocationPath);
imageUploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
#Override
public Task<Uri> then(#NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if(!task.isSuccessful())
{
Toast.makeText(AddProductDataActivity.this, "Task Unsuccessful", Toast.LENGTH_SHORT).show();
}
return img3Store.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
#Override
public void onComplete(#NonNull Task<Uri> task) {
if(task.isSuccessful())
{
String image_3_url = task.getResult().toString();
objectMap.put("image3_url",image_3_url);
}
else
{
Toast.makeText(AddProductDataActivity.this, task.getException().toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
else
{
objectMap.put("image3_url","");
}
objectFireBaseFireStore.collection("images").document(productId).set(objectMap).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Toast.makeText(AddProductDataActivity.this, "Product Added Successfully.", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(AddProductDataActivity.this, "Error in Adding Product. Please Try Again.\n"+e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, #Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
case 30:
try
{
if(resultCode == RESULT_OK && data != null && data.getData() != null)
{
image3LocationPath = data.getData();
Bitmap objectBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), image3LocationPath);
addProductImage3.setImageBitmap(objectBitmap);
}
}
catch (Exception e)
{
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
break;
default:
break;
}
private String getExtension(Uri uri){
try
{
ContentResolver objectContentResolver = getContentResolver();
MimeTypeMap objectMimeTypeMap = MimeTypeMap.getSingleton();
return objectMimeTypeMap.getExtensionFromMimeType(objectContentResolver.getType(uri));
}
catch (Exception e)
{
Toast.makeText(AddProductDataActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
return null;
}
}
}
Your code
objectFireBaseFireStore.collection("images").document(productId).set(objectMap)
executes before
objectMap.put("image3_url",image_3_url)
Which means when you are setting your url, your objectMap does not have the key image3_url
Try to set values to database inside onComplete() or use different workaround to set only the url.
You forgot to add your HashMap to Database Reference of Firebase.
This is reference from my current project code.
private void uploadVideo() {
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
final StorageReference riversRef = mStorageRef.child(Constants.STORAGE_PATH + "/" + mFinalUploadUri.getLastPathSegment());
riversRef.putFile(mFinalUploadUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
#Override
public Task<Uri> then(#NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw Objects.requireNonNull(task.getException());
}
// Continue with the task to get the download URL
return riversRef.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
#Override
public void onComplete(#NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
FirebaseFirestore database = FirebaseFirestore.getInstance();
String mSelectedCategory = binding.categorySpinner.getSelectedItem().toString();
DocumentReference newDocumentReference = database.collection(PENDING_PATH).document();
VideoModel videoModel = new VideoModel();
videoModel.setDocumentId(newDocumentReference.getId());
videoModel.setTitle(mTitle);
videoModel.setCategory(mSelectedCategory);
//videoModel.setTime(FieldValue.serverTimestamp());
videoModel.setUrl(downloadUri != null ? downloadUri.toString() : null);
newDocumentReference.set(videoModel).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
binding.progressBar.setVisibility(View.GONE);
binding.button.setVisibility(View.VISIBLE);
binding.videoView.setVisibility(View.GONE);
selectedUri = null;
Toast.makeText(AdminVideoUploadActivity.this, R.string.uploaded_successfully, Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(AdminVideoUploadActivity.this, R.string.failed_to_upload, Toast.LENGTH_SHORT).show();
}
});
}
}
});
}
Now you can check code and find where you have done mistake. Just add lines of code of inserting in database.
Thank you.