1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question SearchView question file.dat

Discussion in 'Android Questions' started by gregorio_adrian_gimenez, Jul 23, 2019.

  1. gregorio_adrian_gimenez

    gregorio_adrian_gimenez Active Member Licensed User

    sorry to ask this question, maybe it's very basic
    I don't know how to replace existing files on searchview so you can use a flat txt file that contains country names.
    who can help me? I don't understand this from the index and files.dat
    Code:
    Private Sub LoadIndices
        
    Dim ser As B4XSerializator
        ser.Tag = 
    1
        ser.ConvertBytesToObjectAsync(
    Bit.InputStreamToBytes(File.OpenInput(File.DirAssets,"first.dat")),"ser")
        
        

    End Sub

    Private Sub ser_BytesToObject (Success As Boolean, NewObject As Object)
        
    Log(NewObject)
        ProgressBar1.Visible = 
    False
        
    If Success Then
            
    Dim ser As B4XSerializator = Sender
            
    Log($"BytesToObject: ${ser.Tag}"$)
            
    If ser.Tag = 1 Then
                firstIndex = NewObject
                sv.LoadFirst(firstIndex)
                ser.Tag = 
    2
                
    'read the secondary index
                ser.ConvertBytesToObjectAsync( _
                    
    Bit.InputStreamToBytes(File.OpenInput(File.DirAssets, "second.dat")), "ser")
            
    Else if ser.Tag = 2 Then
                secondIndex = NewObject
                
                        
    End If   
        
    End If
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You are using code from the more complex example that shows how to load large files asynchronously.
    In most cases you should use the simpler option:
    Code:
    SearchView.SetItems(File.ReadList(your text file))
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice