In the app folder i don't find the file, the DefaultFileScope is App
if I use
File pngFile = new File("sdcard/TeamLogo.png");
instead of
File pngFile = new File(activity.getFilesDir(), fileName);
the file is createad correctly
Here is some example code I have that returns an asset file (as a tempFile - in that same directory), you will see that this is all done "inside" the extension
@SimpleFunction(description = "Returns asset as File. This works only for a compiled app. Your file must have an extension, and there should be no 'dots' " +
"in the file other than the one that " +
"separates the name from the extension")
public String GetAsset(String filename) throws IOException {
File file = File.createTempFile("temp", ("." + filename.split("\\.")[1].toLowerCase()));
filePath = file.getAbsolutePath();
InputStream in = context.getAssets().open(filename);
int size = in.available();
byte[] buffer = new byte[size];
in.read(buffer);
in.close();
FileOutputStream out = new FileOutputStream(filePath);
out.write(buffer);
out.close();
return filePath;
}
Hi @TIMAI2 ,
thank You for your help, in my case
int size = in.available(); is 0
I suppose because my InputStream is = httpConn.getInputStream
and in your case
InputStream in = context.getAssets().open(filename);
Anyway, I found the problem, the file was create correctly in the ASD folder with my extension but to display the image if I use the absolute path:
data/user/0/app//files/fileName.png
the file is not shown in the image component
Instead if I use the full path:
file:///data/user/0/app//files/fileName.png
The file is correctly shown int the image component.