Java 通过android更改存储在parse中的图像
我正在尝试更新通过android应用程序保存在parse中的图像,我可以检索它并将其加载到应用程序中,但我无法保存我选择用来替换旧图像的新图像。我就是这样做的,它只保存当前状态的文件,不进行解析。这是我目前拥有的代码,它没有按照我希望的方式工作。请帮忙 代码如下Java 通过android更改存储在parse中的图像,java,android,button,parse-platform,android-imageview,Java,Android,Button,Parse Platform,Android Imageview,我正在尝试更新通过android应用程序保存在parse中的图像,我可以检索它并将其加载到应用程序中,但我无法保存我选择用来替换旧图像的新图像。我就是这样做的,它只保存当前状态的文件,不进行解析。这是我目前拥有的代码,它没有按照我希望的方式工作。请帮忙 代码如下 protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK)
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == LOAD_IMAGE_RESULTS) {
Uri pickedImage = data.getData();
InputStream inputStream;
try {
inputStream = getContentResolver().openInputStream(pickedImage);
Bitmap selectedImages = BitmapFactory.decodeStream(inputStream);
imageSelected.setImageBitmap(selectedImages);
selectedImages = ((BitmapDrawable) imageSelected.getDrawable()).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
selectedImages.compress(Bitmap.CompressFormat.PNG, 5, stream);
byte[] imageRec = stream.toByteArray();
file = new ParseFile("profileUpdate.png", imageRec);
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (null == e)
currentUser.put("ProfilePicture", file);
}
});
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Unable to load image",
Toast.LENGTH_LONG).show();
}
}
}
}
我刚刚添加了currentUser.savenbackground();currentUser.put之后的行(“ProfilePicture”,文件);并添加了currentUser.remove(“ProfilePicture”);在它之前,它起作用了