I am using the following method to save information.
private void saveUserData() {
progressDialog.setTitle("Account Settings");
progressDialog.setMessage("Please wait while settings are being changed...");
progressDialog.show();
final StorageReference imageRef = storageReference
.child(FirebaseAuth.getInstance().getCurrentUser().getUid());
imageRef.putFile(imageUri);
}
I have removed some lines of code for accessing the database.
This the log cat description.
E/StorageException: StorageException has occurred. An unknown error occurred, please check the HTTP result code and inner exception for server response. Code: -13000 HttpResult: 0 E/AndroidRuntime: FATAL EXCEPTION: FirebaseStorage-Upload-1
I seached this error code and found
case unknown = -13000
The app doesn't crash when I comment this line.
imageRef.putFile(imageUri);
On a side note, I am able to save text info successfully and even retrieve it from the database.
EDIT
Here is the code.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
storageReference = FirebaseStorage.getInstance()
.getReference().child("Profile Pictures");
profileImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, galleryPick);
}
});
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveUserData();
}
});
retrieveUserInformation();
}
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == galleryPick && resultCode == RESULT_OK && data != null) {
imageUri = data.getData();
profileImageView.setImageURI(imageUri);
}
}
FirebaseStorage firebaseStorage = FirebaseStorage.getInstance()
??? about .getInstance() ??? – s. srichomthongimageUri
, you're trying to upload to Storage from a URL, which is not supported. You'll first have to download the data from the URL, and then upload it to Storage. – Frank van Puffelen