Android Question Searchview File

Peter Lewis

Active Member
Licensed User
Longtime User
In the Example of Searchview there is a file called Cities.txt.

After installing the app on my phone I looked for this file and cannot find it on my android device. There is also no information how this file is populated and from where.

It this an Android system file ?

Could I make my own file in this same format? is it comma delimited ? or plain text.

Thank you

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If FirstTime Then
        Dim cities As List = File.ReadList(File.DirAssets, "Cities.txt")
        'As an optimization we store the index as a process global variable
        'and only build it once.
        index = SearchView1.SetItems(cities)
    Else
        SearchView1.SetIndex(index)
    End If
    ime.Initialize("ime")
    ime.AddHeightChangedEvent
End Sub
 

klaus

Expert
Licensed User
Longtime User
You won't find it because it is included in the apk file in Files.DirAssets.
But you find it on your PC in the Files folder of the project.
It is a simple text file, one city per line.
A small extract:
Canberra
Cape Town
Caracas
Cardiff
Chengdu
Chennai
Chiba
Chicago, IL

You can of course create your own file.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
1. In the IDE click on the bottom right hand side where it says; 'Files Manager'. when you hover over the correct tab.
2. Right click and select' Open Files Folder'. You will be able to see on your PC.
3.You cannot see it on the tablet because it is part of the assets folder.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
You won't find it because it is included in the apk file in Files.DirAssets.
But you find it on your PC in the Files folder of the project.
It is a simple text file, one city per line.
A small extract:
Canberra
Cape Town
Caracas
Cardiff
Chengdu
Chennai
Chiba
Chicago, IL

You can of course create your own file.

Hi Klaus

So it is a file I will be able to update when running the app

Thx
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Yes.
You can either copy it somewhere else on the device, for example File.DirInternal.
Then read it from there.
For the update, I'd suggest you, to update the List and when you leave the program write the List to the device with File.WriteList.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Thank you , I just need to update that file from the SQL server file once a day with the latest contents of the server file. I will try specifying DirInternal,
 
Upvote 0
Top