Android Question Progressive key in a Firebase database

dibesw

Active Member
Licensed User
Longtime User
I want create a row into my Firebase database: code is:

B4X:
Sub insert_voce
    Dim mData As Map
    mData.Initialize
    Dim s As String
    S=EditText1.Text
    EditText1.Text=S.Substring2(0,1).ToUppercase & S.SubString(1)

    mData.Put("nome", EditText1.Text)
    count=count+1
    Dim JSONGenerator As JSONGenerator
    JSONGenerator.Initialize(mData)
 
    Dim JSONstring As String
    JSONstring = JSONGenerator.ToPrettyString(0)
 
    Dim req As OkHttpRequest
    req.InitializePut2(Main.strPath3 & "Medici/" & count & ".json" , JSONstring.GetBytes("UTF8"))
    req.SetContentType("application/json")
    Dim exec As OkHttpClient
    exec.Initialize("b")
    exec.Execute(req, "1")
End Sub

This is Firebase database:

snap.png


My rules is:

snap1.png


now calculate count manually.
Is there a way for create automatic index?

Thanks in advance
 
Top