0

I am very new to this, I am using the sample ClassicKotlin from Android repository. There is a "media-feed.json" file in the asset which I would like to move it to a remote location instead of local file. Here is what I am changing . Part of the code is this now: the file name is :"TvMediaSynchronizer.kt"

/** Fetches the metadata feed from our assets folder and parses its metadata */
private fun parseMediaFeed(context: Context): FeedParseResult {
// Reads JSON input into a JSONArray
// We are using a local file, in your app you most likely will be using a remote URL
    val stream = context.resources.assets.open("**media-feed.json**")
    val data = JSONObject(
    String(stream.readBytes(), StandardCharsets.UTF_8))
Instead of "media-feed.json" I typed "**https://sample.com/uploads/media-feed.json**"
Alex
  • 95
  • 8
  • Files in assets cannot be moved as they are read only. You can make a copy. – blackapps Jan 26 '22 at 04:54
  • I am trying to make it to read the copy of that JSON file I placed in my site. – Alex Jan 26 '22 at 14:40
  • ??? What did you say? I dont understand. – blackapps Jan 26 '22 at 14:56
  • I am trying to make the app read the JSON file from a remote place instead of a local place. so I made a copy of that JSON file and put it in my website, but I am not sure how to insert the URL link into the ("TvMediaSynchronizer.kt") file. – Alex Jan 26 '22 at 15:55
  • Then why are you speaking about asset and resources assets! And about which url are you talking? And at runtime you wanna insert an url in a kotlin file? What is this about? – blackapps Jan 26 '22 at 16:05
  • I am trying to use a sample android app and side load it to my TV , then put my own live TV streaming channels links , so I would like to have the App to read an external file for those streaming links and when I want to I can change links and images , so I dont have to side load the app again every time I change something, because now it reads a local file which is nested inside the asset folder. I hope this make sense. – Alex Jan 26 '22 at 16:24
  • Reading links/urls from a remote file on internet i understand. After that you could use those urls. All clear. But putting those files in a .kt/kotlin file is abacadabra. – blackapps Jan 26 '22 at 16:34
  • So you should start with downloading that -remote- file from internet. What is the problem doing so? – blackapps Jan 26 '22 at 16:36
  • When I open the .kt file there is a this section that reads: "// We are using a local file, in your app you most likely will be using a remote URL val stream = context.resources.assets.open("media-feed.json") " So I assume I need to somehow change the .kt file to read a remote file instead of that local JSON file. I already have my live TV links – Alex Jan 26 '22 at 17:13

0 Answers0