@SimpleFunction(description = “ReadFile”)
public String LoadData(String inFile) {
String tContents = “”;
try {
InputStream stream =contex.getAssets().open(inFile);
int size = stream.available();
byte[] buffer = new byte[size];
stream.read(buffer);
stream.close();
tContents = new String(buffer);
} catch (IOException e) {
// Handle exceptions here
}
return tContents;
}
Permission are setted.
I writed this method in an extension’ for read a file located in asset.
When i compile the extension there are no errors but thr return of the method is an empty string eithet in develop mode either in compiled apk.
Then i have uptated the method:
SimpleFunction(description = “Male”)
public String LoadData(String inFile) {
String tContents = “”;
File file = context.getExternalFilesDir(null);
ASD=file.toString();
String asd= ASD+inFile+".txt";
try {
InputStream stream =new FileInputStream(asd);
int size = stream.available();
byte[] buffer = new byte[size];
stream.read(buffer);
stream.close();
tContents = new String(buffer);
} catch (IOException e) {
// Handle exceptions here
}
return tContents;
}
But the result is always an empty string
Any suggestion ?