我的问题是从 firestore 获取文档 ID。
我如何获取 Users/documentid/Comments/documentid ?
数据类:
public class BlogPostId {
@Exclude
public String BlogPostId;
public <T extends BlogPostId> T withId(@NonNull final String id) {
this.BlogPostId = id;
return (T) this;
}
}
添加活动:
private String blog_post_id;
Oncreate
blog_post_id = getIntent().getStringExtra("blog_post_id");
btn click
final String descff = icerikedit.getText().toString();
Map<String, Object> commentsMap = new HashMap<>();
commentsMap.put("descff", descff);
commentsMap.put("user_id", current_user_id);
commentsMap.put("timestamp", FieldValue.serverTimestamp());
firebaseFirestore.collection("Users/"+blog_post_id+"/Comments").add(commentsMap).addOnCompleteListener(new OnCompleteListener<DocumentReference>() {
@Override
public void onComplete(@NonNull Task<DocumentReference> task) {
if(task.isSuccessful()){
Toast.makeText(FFicerikAdd.this, "Başarılı efe!", Toast.LENGTH_SHORT).show();
Intent sab=new Intent(getApplicationContext(),FFicerik.class);
sab.putExtra("blog_post_id",blog_post_id);
startActivity(sab);
}
尚方宝剑之说
相关分类