Search code examples
luacoronasdkinternal-storage

Access internal storage specific folder in Corona SDK


I understand this reads the file saved in the app document directory:

    filePath = system.pathForFile( "text.txt", system.DocumentsDirectory )

I need to read a file from from another folder rather than my app, say, folder that exist under "internal storage/download" folder of any mobile, would anyone what to put in the above line of code instead of system.DocumentsDirectory


Solution

  • The following code worked. However, the sdcard actually means internal storage in the app. Also the middle two lines is necessary for the code to work even though the fourth line refers to first line directly.

        filePath = "/sdcard/coordinates.txt"
        local file = io.open( filePath, "r" )
        local contents = file:read( "*a" )
          for line in io.lines(filePath) do  
            ii=ii+1
            points[ii] = line
            b1 = points[ii]
             c2 = 1
             for i in string.gmatch(b1, "%S+") do
                b={}
                b[c2]=i
                if c2 ==1 then bore[ii] = b[c2] end
                if c2 ==2 then x[ii] = b[c2] end
                if c2 ==3 then y[ii] = b[c2] end
                c2=c2+1
    end