https://kotlinlang.org logo
#android
Title
# android
m

minucha

12/29/2019, 8:51 PM
Hi, I am developing an application where I basically download a video file and show it in the 
HistoryActivity
. My video model has 
name
authorName
authorImageUrl
videoDescription
 and every time I download a video, I store the video info in the 
SharedPreference
 so that I can list all the videos with their description in the 
HistoryActivity
. I am using video’s 
name
 property as an ID to connect the video with its description I stored in the 
SharedPreference
. However, when user changes the name of the video using other apps, I am losing the ID. So the question: Is there any way that I can use as an ID for video file or any other file type?
a

Adam Powell

12/29/2019, 9:09 PM
without getting too far into the question of what you want to consider, "identity" for a video, it sounds like you're defining video identity to be an entry in your downloaded files record. You want the metadata to be able to change without affecting the identity, though the bytes on disk and the filename of the bytes on disk are probably not going to change. If the user deletes a file and redownloads it, that's a "new" video, from your description.
so you can probably generate a random
UUID
and store it alongside the name and other metadata, then always refer to a video by its uuid, not by its name. The uuid will never change for a given downloaded file.
m

minucha

12/29/2019, 9:18 PM
Hmm, good point, I see it now 🙂 thanks.
3 Views