android - How to pin a ParseObject with a ParseFile to the Parse Local Datastore in OFFLINE? -
android - How to pin a ParseObject with a ParseFile to the Parse Local Datastore in OFFLINE? -
i using next code store parseobject parsefile. have enabled parse local datastore in application subclass. code storing instance of parseobject in local datastore , in parse server when application in connected internet.
final parsefile file = new parsefile(position + ".mp4", data); file.saveinbackground(new savecallback() { @override public void done(parseexception e) { parseobject po = new parseobject("recordings"); po.put("code", position); po.put("name", myname); po.put("file", file); po.saveeventually(); } });
same code when app not connected net throwing next exception. java.lang.illegalstateexception: unable encode unsaved parsefile. , app crashing. object not stored in local datastore.
so how can store parseobject parsefile in parse local datastore when there no internet?
i have solved problem storing bytes of file parseobject. when want file, writing bytes file.
my requirement store sound recording file name in parse. followed these steps: 1. byte array of file 2. set byte array parseobject 3. phone call parseobject#saveeventually()
code:
file file = new file(filepath); fileinputstream fis = null; seek { fis = new fileinputstream(file); byte data[] = new byte[(int) file.length()]; fis.read(data); parseobject obj = new parseobject("recordings"); obj.put("name", name); obj.put("data", data); obj.saveeventually(); } grab (ioexception e) { e.printstacktrace(); }
android parse.com
Comments
Post a Comment