I'm converting my app to B4XPages and i want to know if a page already exist ,is there a way to do it?
I've just started delving in to B4XPages
Me too, so I don't know if a similar function exists but you could create a Map with references to all your B4XPages.
When you create and add the page to B4XPages:
B4XPages.AddPage("Page7", Page7)
mapPages.Put("Page7", Page7)
If mapPages.ContainsKey("Page7") Then
Another way could be:
Public Sub PageExists(PageID As String) As Boolean
Dim Result As Boolean = True
Try
B4XPages.GetPage(PageID)
Catch
Result = False
End Try
Return Result
End Sub
but you will get an error message in the log (although the function will work without crashing your app).
Note that if your need was to avoid to add a page more than once, there are no problems, because B4XPages.AddPage and B4XPages.AddPageAndCreate do not add duplicates.
P.S. All this, as Erel wrote, is not needed, since you cannot remove a page from B4XPages (I did not know, I checked only now), you can only Close a page.