Z zxxdaro Member Licensed User Longtime User Nov 12, 2011 #1 Can someone help me solve this problem please. Here is a piece of code out of a larger chunk. It is the relevant piece. Sub Activity_Create(FirstTime As Boolean) Dim Reader As TextReader Reader.Initialize(File.OpenInput(File.DirInternal,"testandroid.txt")) Dim line As String line=Reader.ReadLine Do While line <> Null It generates an error message REader.Initialize(File.OpenInput(File.DirInternal,"testandroid.txt")) java.io.FileNotFoundException:/data/data/testv1.prog/files/testandroid.txt I have created the file and everything I have read suggests that it should be readable. Of course as a newbie I am probably making some elementary mistake but I would welcome help in finding the solution.
Can someone help me solve this problem please. Here is a piece of code out of a larger chunk. It is the relevant piece. Sub Activity_Create(FirstTime As Boolean) Dim Reader As TextReader Reader.Initialize(File.OpenInput(File.DirInternal,"testandroid.txt")) Dim line As String line=Reader.ReadLine Do While line <> Null It generates an error message REader.Initialize(File.OpenInput(File.DirInternal,"testandroid.txt")) java.io.FileNotFoundException:/data/data/testv1.prog/files/testandroid.txt I have created the file and everything I have read suggests that it should be readable. Of course as a newbie I am probably making some elementary mistake but I would welcome help in finding the solution.
Erel B4X founder Staff member Licensed User Longtime User Nov 13, 2011 #2 Where is the code that creates the file? Note that you can use File.ReadList to read the complete file into a list of lines. Upvote 0
Where is the code that creates the file? Note that you can use File.ReadList to read the complete file into a list of lines.
Z zxxdaro Member Licensed User Longtime User Nov 13, 2011 #3 I created the file as part of the application as advised I cannot as yet post urls, even urls to this forum! but look up my previous posts Here is part of the url. basic4android-updates-questions/12526-creating-files-external-but-part-app.html Upvote 0
I created the file as part of the application as advised I cannot as yet post urls, even urls to this forum! but look up my previous posts Here is part of the url. basic4android-updates-questions/12526-creating-files-external-but-part-app.html
klaus Expert Licensed User Longtime User Nov 13, 2011 #4 If you added the file with the file manager in the IDE, you should use: Code: Reader.Initialize(File.OpenInput([COLOR=Red]File.DirAssets[/COLOR], "testandroid.txt")) Best regards. Upvote 0
If you added the file with the file manager in the IDE, you should use: Code: Reader.Initialize(File.OpenInput([COLOR=Red]File.DirAssets[/COLOR], "testandroid.txt")) Best regards.
Z zxxdaro Member Licensed User Longtime User Nov 13, 2011 #5 Thank you both for your help. That piece of code now works. Yes I was aware of the ability to read the file in at one go. I am following an existing piece of code that I wrote some time ago in Perl and I decided it was best for the moment to translate that code as closely as possible. It does occur to me that an expanded section on reading this particular kind of files would make a useful addition to the wiki, but I think I should wait a while until I am more familiar with the language before I contribute. So far I think that Basic4 Android is a far better approach than the java one. I am getting far further much faster. Upvote 0
Thank you both for your help. That piece of code now works. Yes I was aware of the ability to read the file in at one go. I am following an existing piece of code that I wrote some time ago in Perl and I decided it was best for the moment to translate that code as closely as possible. It does occur to me that an expanded section on reading this particular kind of files would make a useful addition to the wiki, but I think I should wait a while until I am more familiar with the language before I contribute. So far I think that Basic4 Android is a far better approach than the java one. I am getting far further much faster.