Android Parse.com file: Save File to SDCard

168 Views Asked by At

I want call one file to parse, after I save the file to the SDCard. I'm sorry, my English is not good. Can you help me? Save file in external storage from Parse.com. This is my code:

 // Capture button clicks
        btnUpload.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                // Locate the image in res > drawable-hdpi

                for (int i = 0; i < mangImage.length; i++) {
                    InputStream in = getResources().openRawResource(mangImage[i]);
                    try {

                        ParseObject imgupload = new ParseObject("Map");
                        byte[] data = getBytesFromInputStream(in);
                        String nameFile = getResources().getResourceEntryName(mangImage[i])+".tmx";
                        ParseFile file = new ParseFile(nameFile,
                                                       data);
//                    byte[] image = stream.toByteArray();
//                    ParseFile file = new ParseFile("" + mangImage[i] + ".tmx", image);
                        file.saveInBackground();

                        // Create a column named "ImageName" and set the string

                        imgupload.put("nameMap",
                                      "" +nameFile);

                        // Create a column named "ImageFile" and insert the image
                        imgupload.put("fileMap", file);

                        // Create the class and the columns
                        imgupload.saveInBackground();

                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                }

                Toast.makeText(UploadActivity.this,
                               "Image Uploaded",
                               Toast.LENGTH_SHORT)
                     .show();
            }
        });
0

There are 0 best solutions below