private void savePicture() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.PNG, 100, stream);
final ParseFile file = new ParseFile("pic.png", stream.toByteArray());
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e != null) {
Toast.makeText(GenerateReportActivity.this,
"Couldn't save image", Toast.LENGTH_LONG);
} else {
try {
newItem.put("image", file);
myReports.put(newItem);
} catch (JSONException ex) {
Utility.showMessage(ex.getMessage(),
"JSON ERROR PICTURE", GenerateReportActivity.this);
}
}
}
});
imgTakenPhoto.setImageBitmap(null);
imgTakenPhoto.destroyDrawingCache();
}
在这种方法中,我尝试保存从Camera中捕获的图像(当前保存为Bitmap)并且我想将image属性添加到我的JSONObject newItem
。然后将newItem
添加到myReports
,这是一个JSONArray。然后将myReports
放入密钥"myReports"
下的ParseObject中,然后调用saveInBackground()
。但问题是,当我查看数据库时,没有显示带有picture属性的JSONObject。