0
我試圖保存與我的圖像類有關係的項目。我可以節省的項目,我可以seperately保存圖像,但是當我在他們的關係,儲蓄如果拋出這個錯誤:saveInBackground拋出異常「未保存的ParseObject」
unable to encode an association with an unsaved ParseObject
這裏是我的代碼:
myAdvert = new ParseObject("Items");
myAdvert.put("title", "some title");
if (pic1Set) {
Bitmap bitmap = ((BitmapDrawable) pic1.getDrawable())
.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
myPhoto1 = new ParseObject("Images");
filePhoto = new ParseFile("image.png", byteArray);
filePhoto.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
myPhoto1.put("image", filePhoto);
ParseRelation relation = myAdvert.getRelation("pictures");
relation.add(myPhoto1);
myAdvert.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
// TODO Auto-generated method stub
if (e != null) {
--> // THIS IS WHERE THE ERROR IS THROWN!!!!
Log.d("error", e.toString());
} else {
}
}
});
} else {
Log.d("wow, error", e.toString());
Toast.makeText(getApplicationContext(),
"Error saving: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
});
您只需保存parseObject,然後將其添加到關係即可。 – 2014-12-12 20:44:12
嗯,我並沒有試圖添加一個關係 - 它試圖保存一個對象,有時候在嘗試註冊一個用戶時發生在我身上。 我猜測它的ACL需要鏈接到用戶的本地數據存儲中的對象 - 並且當成爲在線時,某些東西正在變得混亂。 – jBOB 2014-12-14 13:05:41