热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

我想更新用户个人资料数据,但所有数据已更新,图像数据已删除?

我想更新除图像之外的所有用户个人资料数据。我不希望更改图像ut,当我单击“

我想更新除图像之外的所有用户个人资料数据。我不希望更改图像ut,当我单击“更新”按钮时,所有数据都将最终更新,但是图像已从Firebase中删除,请提前帮助我。谢谢。我应用的更新功能是(btn_update.setOnclicklistener)。我想更新除图像之外的所有用户配置文件数据。我不希望更改图像ut,当我单击更新按钮时所有数据都已更新但图像已从Firebase中删除时,请提前帮助我。谢谢。我应用的更新功能是(btn_update.setOnclicklistener)。

My Updated Classs
package com.deitel.fragment_table_layout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatactivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.deitel.fragment_table_layout.ModelClass.StudentRecord;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.Datasnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.util.HashMap;
import java.util.Map;
public class Updata_Data extends AppCompatactivity {
private FirebaseAuth auth;
private FirebaseAuth.AuthStateListener authStateListener;
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference ref = database.getReference();
FirebaseStorage firebaseStorage;
private String UserId;
ImageView imageView;
EditText edit_name,edit_qualification,edit_contact,edit_age,edit_address,edit_city,edit_email;
Button btn_update,btn_discard;
String name,email,qualification,contact,age,address,city,Imagepath;
private static int PICK_IMAGE_REQUEST = 1;
Uri filepath;
private StorageReference storageReference;
public void onactivityResult(int requestCode,int resultCode,@Nullable Intent data) {
super.onactivityResult(requestCode,resultCode,data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK ) {
filepath = data.getData();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_updata__data);
auth = FirebaseAuth.getInstance();
firebaseStorage = FirebaseStorage.getInstance();
FirebaseUser user = auth.getcurrentUser();
UserId = user.getUid();
edit_name = findViewById(R.id.edit_name);
edit_qualification = findViewById(R.id.edit_qualification);
edit_cOntact= findViewById(R.id.edit_contact);
edit_age = findViewById(R.id.edit_age);
edit_address = findViewById(R.id.edit_address);
edit_city = findViewById(R.id.edit_city);
edit_email=findViewById(R.id.edit_email);
imageView = findViewById(R.id.edit_imageview);
btn_update = findViewById(R.id.btn_update);
btn_discard = findViewById(R.id.btn_discard);
btn_update.setOnClicklistener(new View.OnClicklistener() {
@Override
public void onClick(View v) {
try {
StudentRecord studentRecord = new StudentRecord();
studentRecord.name = edit_name.getText().toString();
studentRecord.email = edit_email.getText().toString();
studentRecord.qualification = edit_qualification.getText().toString();
studentRecord.cOntact= edit_contact.getText().toString();
studentRecord.age = edit_age.getText().toString();
studentRecord.address = edit_address.getText().toString();
studentRecord.city = edit_city.getText().toString();
final DatabaseReference databasereference = FirebaseDatabase.getInstance().getReference("Record").child(UserId);
databasereference.setvalue(studentRecord);
Toast.makeText(Updata_Data.this,"Data Update Successfully",Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(Updata_Data.this,"Date Update Error",Toast.LENGTH_SHORT).show();
}
}
});
Intent intent = getIntent();
name = intent.getStringExtra("name");
email = intent.getStringExtra("email");
qualification = intent.getStringExtra("qualification");
cOntact= intent.getStringExtra("contact");
age = intent.getStringExtra("age");
address = intent.getStringExtra("address");
city = intent.getStringExtra("city");
edit_name.setText(name);
edit_qualification.setText(qualification);
edit_contact.setText(contact);
edit_age.setText(age);
edit_address.setText(address);
edit_city.setText(city);
authStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
}
};
ref.addValueEventListener( new ValueEventListener() {
@Override
public void onDataChange(@NonNull Datasnapshot datasnapshot) {
showdata(datasnapshot);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
public void showdata(Datasnapshot datasnapshot) {
for (Datasnapshot ds : datasnapshot.getchildren()) {
try {
edit_name.setText(ds.child(UserId).getvalue(StudentRecord.class).getName());
edit_email.setText(ds.child(UserId).getvalue(StudentRecord.class).getEmail());
edit_qualification.setText(ds.child(UserId).getvalue(StudentRecord.class).getQualification());
edit_contact.setText(ds.child(UserId).getvalue(StudentRecord.class).getcontact());
edit_age.setText(ds.child(UserId).getvalue(StudentRecord.class).getage());
edit_city.setText(ds.child(UserId).getvalue(StudentRecord.class).getcity());
edit_address.setText(ds.child(UserId).getvalue(StudentRecord.class).getaddress());
// Glide.with(getapplicationContext()).load(ds.child(UserId).getvalue(StudentRecord.class).getImageadress()).into(imageView);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}





推荐阅读
author-avatar
江自流
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有