B4X:
Sub GetStringFromFile(strFile As String) As ResumableSub
Dim lBytes As Long
Dim strResult As String
If File.Exists(File.DirInternal, strFile) = False Then
Wait For (File.CopyAsync(File.DirAssets, strFile, File.DirInternal, strFile)) Complete (bSuccess As Boolean)
Log("bSuccess: " & bSuccess)
End If
'RAF is RandomAccessFile
RAF.Initialize(File.DirInternal, strFile, True) 'fails in debug mode with java.io.FileNotFoundException:
'/data/user/0/b4a.exampleljjll/files/db_folder.txt: open failed:
'ENOENT (No such file or directory)
lBytes = RAF.Size
'this will be a zero-based UTF8 byte array
'-----------------------------------------
Dim arrBytes(lBytes) As Byte
RAF.ReadBytes(arrBytes, 0, lBytes, 0)
strResult = BytesToString(arrBytes, 0, lBytes, "UTF-8")
Return strResult
End Sub
RBS