gpt4 book ai didi

android - 在 parse.com 中动态创建文件数据类型的列 android

转载 作者:行者123 更新时间:2023-11-30 02:53:24 25 4
gpt4 key购买 nike

使用android代码在parse.com中动态生成文件数据类型的列

 ParseObject tableName = new ParseObject("NewTable");
tableName.put("columnOne", "string"); // string
tableName.put("columnTwo", 12); // integer
tableName.put("Filedata", ); <----------Here must be file data type
tableName.saveInBackground();

最佳答案

以文件数据类型存储---

获取 byte[] 形式的数据,然后用它创建一个 ParseFile

在这个例子中,我们将只使用一个字符串:

byte[] data = "Working at Parse is great!".getBytes();
ParseFile file = new ParseFile("filedata.txt", data);
file.saveInBackground();

最后,保存完成后,您可以像任何其他数据一样将 ParseFile 关联到 ParseObject 上:

ParseObject tableName = new ParseObject("NewTable");
tableName.put("columnOne", "string"); // string
tableName.put("columnTwo", 12); // integer
tableName.saveInBackground();
tableName.put("Filedata", file);
tableName.saveInBackground();

取回它涉及调用 ParseObject 上的 getData 变体之一。在这里,我们从另一个对象中检索 Filedata 文件:

ParseFile applicantFile = (ParseFile)anotherApplication.get("Filedata");
applicantFile.getDataInBackground(new GetDataCallback() {
public void done(byte[] data, ParseException e) {
if (e == null) {
// data has the bytes for the resume
} else {
// something went wrong
}
}
});

这在 Android Parse Guide. 中有更详尽的解释。

关于android - 在 parse.com 中动态创建文件数据类型的列 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23734726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com