Android Question check if a file excist and show the value

Discussion in 'Android Questions' started by Ricardo Bunschoten, Jul 20, 2015.

  1. Ricardo Bunschoten

    Ricardo Bunschoten Member Licensed User

    I need some help with file checking and showing values

    I am building a kodi installer for a friend

    The installer downloads a file wich is unpacked to a folder

    But now he wants to check if his installed version is older or the same as a updated version online

    I created a version.txt online which holds a value and that value is showned in a label

    Code:
    Sub check_Click
        hc.Initialize(
    "hc")
                        req.InitializeGet(
    "http://download.filmspeler.nl/x/Version.txt"'<--- Replace this with your info
                    hc.Execute(req, 1)
                
    End Sub
    ######## Fetch Data ########

    Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)

        Label5.Text = Response.GetString(
    "UTF8")

      
    End Sub

    Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)

        
    Msgbox("Error in app: " & Response.GetString("UTF8"), "")
                  
                    Response.Release
                  
                    
    End Sub

    This works fine but now i want also label that shows the installed version

    I want to read the value from version.txt which is located in Android/data/org.xbmc.kodi/files/.kodi

    And show that value of that txt file in a label

    But if that files does not excist i want to create a empy version.txt in the location Android/data/org.xbmc.kodi/files/.kodi.

    I am not sure how to do that.

    Greetz

    Rico
     
  2. walterf25

    walterf25 Well-Known Member Licensed User

    Code:
    If File.Exists("directory where file is""file name") = False Then
            
    File.OpenOutput("directory where you want file""file name"False)
        
    Else
            
    Dim version As String
            version = 
    File.ReadString("directory where file is""file name")
            label1.text = version
        
    End If
    You can do something like this!

    Good luck!
     
    lemonisdead likes this.
  3. Ricardo Bunschoten

    Ricardo Bunschoten Member Licensed User

    Thank you verry much for this.
     
Loading...