如何用java获取本地存储权限_java – Parse:如何从本地数据存储中获取Relation(… fromLocalDatastore())?...

这篇博客探讨了在Java应用中使用Parse框架时如何获取本地存储的Parse对象,特别是涉及文件类型的对象。作者面临的问题是在从本地数据存储中检索已保存的文件数据时遇到困难,希望避免再次从服务器下载。文章详细展示了尝试的代码片段,包括如何查询和存储Parse对象,并提出了可能的解决思路。
摘要由CSDN通过智能技术生成

我正在开发一个应用程序作为学习,我使用Parse(parse.com)作为数据源.

我正在解析我的类的所有对象并保存到具有Parse的本地商店.以下执行下载之一的代码段:

public void noticia_getOrUpdate(boolean isUpdate) throws ParseException {

ParseQuery query = new ParseQuery(Noticia.class);

query.orderByDescending("createdAt");

List lNoticias = null;

try {

if (isUpdate) {

lNoticias = query.whereGreaterThan("updatedAt", this.sPref.ultimaAtualizacao_noticia()).find();

if (!lNoticias.isEmpty())

ParseObject.pinAllInBackground(lNoticias);

} else {

query.whereEqualTo("ativo", true);

lNoticias = query.find();

for (Noticia noticia : lNoticias) {

if (noticia.getUpdatedAt().getTime() > this.sPref.ultimaAtualizacao_noticia().getTime())

this.sPref.atualiza_noticia(noticia.getUpdatedAt());

}

ParseObject.pinAllInBackground(lNoticias);

this.sPref.atualiza_isUpdate(true);

}

} catch (ParseException e) {

e.printStackTrace();

}

}

问题是我正在下载我的所有类,一个是文件类型,是一个用作我的新闻图像的文件(“Noticia”).我可以下载并存储所有现场数据存储,但无法使用以下代码进行恢复:

public static byte[] NoticiaMidiaRelation(Noticia noticia) {

try {

ParseRelation relation = noticia.getImagem();

Midia midia = relation.getQuery().fromLocalDatastore.whereEqualTo("ativo", true).getFirst();

if (midia != null && midia.getFileData() != null)

return midia.getFileData();

} catch (ParseException e) {

e.printStackTrace();

}

return null;

}

如果退出“fromLocalDatastore”查询,他会搜索服务器并正确地提供文件,但不想再追求它,因为如上所述,已经有相同的图像存储在本地数据存储中.

另一种方法是获得媒体ID之间的关系,之后执行搜索比较本地商店中的ObjectId,但我认为属性“父”没有办法.但如果有的话,可以用作解决方案.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值