[Bug] OutputStream

sioconcept

Active Member
Licensed User
Longtime User
I try to save the bitmap in a file, but i've this error :


Out = File.OpenOutput(File.DirAssets, "photo.jpg", False)
java.io.FileNotFoundException: /AssetsDir/photo.jpg (No such file or directory)

B4X:
   For i = 0 To listOfContacts.Size - 1
      Dim Contact As Contact
      Contact = listOfContacts.Get(i)
      Dim photo As Bitmap
      photo = Contact.GetPhoto
      If photo <> Null Then
         Log(photo.Height)
         Dim Out As OutputStream
         Out = File.OpenOutput(File.DirAssets, "photo.jpg", False)
         photo.WriteToStream(Out, 80, "JPEG")

What's the problem ? OuputStream create the file if isn't exist normally.
 

sioconcept

Active Member
Licensed User
Longtime User
Hey me, are you serious ? Read the wiki !

File.DirAssets

These are files distributed with the app in the apk. Files in .DirAssets can be read but not written. In order for files to be included in the apk by B4A, they must be added in the Files tab of the IDE. For adding subfolders to the Files folder, see this post.

File.DirInternal / File.DirInternalCache

These two folders are stored in the main memory and are private to your application.

So, use File.DirInternal :sign0060:
 
Top