I’m currently building a reasonably big Android app and I was wondering how I could best store images for my tabels. Currently I have a ‘Vacation’ table and that table had 3 columns, allowing each vacation to have 3 images.
Currently this works, but it isn’t ideal and it should be changed to a more versatile number.
I’ve been thinking about how to do it and I’ve come up with the following idea, though I’m not sure if it’s efficient. I added an extra tabel, called ‘Image’, which contains an ‘ImageID’ (string) field and an ‘Image’ (file/picture) field.
Now I’m not sure how I’d best link the images of a vacation to its vacation. I’ve thought about adding an attribute to ‘Vacation’, which would contain an array of ImageID’s. The downside of this would be that it’d probably require an extra search query, plus I wouldn’t explicitly use Parse’s relations in the table.
Does anybody know how I can solve this problem?
In the Parse Data Browser Online:
I would add a column to your
Vacation class in Parse – we’ll call it “
Images“. When creating this column, select
array as the data type. With arrays you can store almost any type of data in Parse – including images.
In Your App:
What you will need to do in your app is create a
ParseFile for each image, and then put all of those images into an array (I’ll call it:
myArrayOfParseFiles). Then, get the Vacation
ParseObject you are working with (I’ll call it
myVacationObject), and assign the array to the “Images” column in your object like so:
Once you save your object all of the files will automatically be transferred to Parse, and you can see them in the column in the online data browser. You can store almost any reasonable amount of pictures in these arrays, and you can delete/add/modify them as much as you wish in your app and in the data browser.
I am an iOS developer, but the ideas are the same and I tried to reference the Parse Android Docs to make my answer apply to you. Please let me know if you have any additional questions. Good luck!!