How to pin a ParseObject with a ParseFile to the Parse Local Datastore in OFFLINE?

后端 未结 3 1202
忘掉有多难
忘掉有多难 2020-12-10 07:35

I am using the following code to store the ParseObject with a ParseFile. I have enabled Parse local datastore in Application subclass. This code storing an instance of the P

3条回答
  •  失恋的感觉
    2020-12-10 08:08

    I have solved this problem by simply storing the bytes of the file with ParseObject. When I want my file, I am writing those bytes back to a file.

    My requirement was to store a audio recording file with name in the parse. I followed the these steps: 1. Get the byte array of file 2. Put the byte array into ParseObject 3. Call ParseObject#saveEventually()

    Code:

        File file = new File(filePath);
        FileInputStream fis = null;
        try {
            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();
        } catch (IOException e) {
            e.printStackTrace();
        }
    

提交回复
热议问题