Dear All,
I ran in an issue with the external file handling (SD Card). The copy procedure from external device to File.DirDefaultExternal works but the copied (a bitmap) file is not complete. In other words the file is only partially copied.
I created a simple example with one map tile stored on File.DirDefaultExternal and on the external device. I used the file handling method for external devices and the file could be found and the copy process started.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
And the result is as following:
		
		
	
	
		 
	
A portion is missing of Tile2 (copied from external device). This happens if you select an other tile, too. The missing piece is sometimes smaller and larger but it always happens.
May be i missed something essential. Could somebody have a look please.
Wosl
			
			I ran in an issue with the external file handling (SD Card). The copy procedure from external device to File.DirDefaultExternal works but the copied (a bitmap) file is not complete. In other words the file is only partially copied.
I created a simple example with one map tile stored on File.DirDefaultExternal and on the external device. I used the file handling method for external devices and the file could be found and the copy process started.
			
				Copy from SD Card:
			
		
		
		Sub Globals
    Public xui As XUI
    Public Storage As ExternalStorage, lFile As ExternalFile
    Public PersistantUri As String
    Public ZoomImageView1 As ScaleImageView, ZoomImageView2 As ScaleImageView
    Public pnlView As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'######################################################################
'
'  Run example with same tile loaded from different devices
'
'  Load tile form File.DirDefaultExternal and from SDcard
'
'######################################################################
    Private jRectLeft As Int, jRectTop As Int, jRectWidth As Int, jRectHeight As Int
    Private iZ As Int = 13, iX As Int = 4400, iY As Int = 2686
    Private cFileName As String
    Private Outputstream1 As OutputStream
    Private InputStream1 As InputStream
    Private bmp As B4XBitmap
    Log ("Run example with same tile loaded from different devices:")
    Log ("Load tile form File.DirDefaultExternal and from SDcard")
    Log (File.DirDefaultExternal)
    jRectLeft = 0dip
    jRectTop = 0dip
    jRectWidth = Activity.Width
    jRectHeight = Activity.Width / 2
    pnlView.Initialize("")
    Activity.AddView(pnlView, jRectLeft, jRectTop, jRectWidth, jRectHeight)
    pnlView.Color=Colors.Magenta
    
'  Tile 1: loaded from DirDefaultExternal
    jRectLeft = 0dip
    jRectTop = 0dip
    jRectWidth = Activity.Width / 2
    jRectHeight = Activity.Width / 2
    ZoomImageView1.Initialize("")
    pnlView.AddView(ZoomImageView1, jRectLeft, jRectTop, jRectWidth, jRectHeight)
'  Tile 2: loaded from SDCard
    jRectLeft = Activity.Width / 2
    ZoomImageView2.Initialize("")
    pnlView.AddView(ZoomImageView2, jRectLeft, jRectTop, jRectWidth, jRectHeight)
'  Tile 1
    cFileName = "Tile1_" & iZ & "_" & iX & "_" & iY & ".png"
    bmp = xui.LoadBitmap(File.DirDefaultExternal, cFileName)
    ZoomImageView1.Image = bmp
'  Tile 2
    Storage.Initialize (Me, "Storage")
    Storage.SelectDir(True)        ' set to False to define persistant Uri first time
    Wait For Storage_ExternalFolderAvailable
    cFileName = "Tile2_" & iZ & "_" & iX & "_" & iY & ".png"
    lFile = Storage.FindFile(Storage.root, cFileName)
    If lFile.IsInitialized = True And lFile.Length > 0 Then
        InputStream1 = Storage.OpenInputstream(lFile)
        Outputstream1 = File.OpenOutput(File.DirDefaultExternal, cFileName, False)
        File.copy2(InputStream1,Outputstream1)
        bmp = xui.LoadBitmap(File.DirDefaultExternal, cFileName)
        Outputstream1.Close
        ZoomImageView2.Image = bmp
    Else
        Log("File not found on external device")
    End If
    
    Log ("All done")
End SubAnd the result is as following:
A portion is missing of Tile2 (copied from external device). This happens if you select an other tile, too. The missing piece is sometimes smaller and larger but it always happens.
May be i missed something essential. Could somebody have a look please.
Wosl
 
				 
 
		 
 
		 
 
		 
 
		 
 
		