1
parse.com提供了一種在離線模式下使用object.saveEventually()保存ParseObject的方法。調用..這將對象存儲在本地dataStore中,除非與服務器同步完成。Parse.com:Android如何在ParseObject中以離線模式存儲Image ParseFile
問題是,我不能存儲Parsefile像解析對象saveEventully();方法
這裏是我的代碼:
// Locate the image in res > drawable-hdpi
Bitmap bitmap = Util.convertBitmap(ImgLocalPath);
// Convert it to byte
ByteArrayOutputStream stream = new ByteArrayOutputStream();
// Compress image to lower quality scale 1 - 100
bitmap.compress(Bitmap.CompressFormat.JPEG, 100,
stream);
byte[] image = stream.toByteArray();
// Create the ParseFile
final ParseFile file = new ParseFile("NC_Image",
image);
// Upload the image into Parse Cloud
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException arg0) {
final ParseObject ncImagesObj = new ParseObject("NCImages");
ParseObject userObject = ParseObject.createWithoutData("AppUsers", userId);
ncImagesObj.put("user", userObject);
ncImagesObj.put("comment",obj.getComment());
ncImagesObj.put("UserType", UserType);
ncImagesObj.saveEventually(new SaveCallback() {
@Override
public void done(ParseException arg0) {
ncImagesObj.put("image", file);
ncImagesObj.saveInBackground();
System.out
.println("Images Save....");
}
});
}
}, new ProgressCallback() {
@Override
public void done(Integer arg0) {
// TODO Auto-generated method stub
}
});
但是這不會工作 只有「NC_Image」的parseObject創建,但它不能把圖像ParseFile到該對象。
任何人有解決方案...... plz幫助我找到了解決辦法
也許這個答案將幫助您:http://stackoverflow.com/a/26978612 –