Android Question File Created at One Activity cannot read from Another Activity

AndroidMadhu

Active Member
Licensed User
Hello,
I have created one activity [Act1] and created one file named List.txt.
The file can be read successfully from Act1.
But if I want to read the file rom Act2 , the error is coming as below :

B4X:
(FileNotFoundException) java.io.FileNotFoundException: /data/user/0/example.test.example/files/List.txt (No such file or directory)

The below is the code from Act1 [Creation of File] :

B4X:
File.WriteString(File.DirInternal, "List.txt", "resume")

Try
Log(File.ReadString(File.DirInternal, "List.txt"))

Catch
Log(LastException)
End Try

The code from Act2 [read of File]
B4X:
Try
Dim str As String
str=File.ReadString(File.DirInternal, "List.txt")
If str="resume" Then
ResumeActivity=True
Log(str)
End If
File.Delete(File.DirInternal,"List.txt")
Catch
Log(LastException)
End Try

Please advice
 

AndroidMadhu

Active Member
Licensed User
@Erel,
Definitely we will move to B4XPages.. But we are now at the end of the project where the changes will take a huge time and effort.
We are planning to go with B4XPages at our next releases.

Meantime could you please advice for any workaround on this?

Thanks
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Your sample works fine here.
Works for you the first time you start Act2? Where are you creating the file?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What are Act1 and Act2?
Are these Activities in the same project or are they two different projects?
If they are different projects, it will not work.
If they are in the same project it should work.
Can you reproduce the problem in a small project?
Or post your project so we could have a look at it ant see what exactly you have done and how.
 
Upvote 0
Top