Android Question [SOLVED] Problem writing EditText.Text to Map

GMan

Well-Known Member
Licensed User
Longtime User
I want to write 2 simple entries in a map:
B4X:
    If Mappi.IsInitialized = True Then
        EditTextName.InputType = EditTextName.Text
        EditTextemail.InputType = EditTextemail.Text
        Mappi.Put("vornachname",EditTextName.Text)
        Mappi.Put("emailadresse",EditTextemail.Text)
        For Each v As Int In Mappi.Values
            Log(v)
        Next
        File.WriteMap(share & "/testdir","userdata.map",Mappi)
    End If
But i get following error when saving the map:
B4X:
java.lang.NumberFormatException: Invalid double: "John Smith"
The Input_Type is TEXT....
 

DonManfred

Expert
Licensed User
Longtime User
You are using STRING as Keyname but you want to parse them as an Integer.
For Each v As Int In Mappi.Values
Log(v)
Next

B4X:
For Each v As String In Mappi.Values
            Log($"${v}=${Mappi.Get(v)}"$)
        Next
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Tried it with your code, but same error

I also removed the log-part completely - same error

As long as i use integers all works fine o_O
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
This does the Trick (even the EditText-fields are marked as TEXT)

B4X:
EditTextName.InputType = EditTextName.INPUT_TYPE_TEXT
EditTextemail.InputType = EditTextemail.INPUT_TYPE_TEXT

But only when SAVING.

When reading the map with this code:

B4X:
        Mappi = File.ReadMap(share & "/testdir","userdata.map")

            EditTextName.InputType = EditTextName.INPUT_TYPE_TEXT
            EditTextemail.InputType = EditTextemail.INPUT_TYPE_TEXT
            EditTextName.Text = Mappi.Get("vornachname")
            EditTextemail.Text = Mappi.Get("emailadresse")

the same error appears
 
Last edited:
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Solved - THIS works

B4X:
            Mappi = File.ReadMap(share & "/testdir","userdata.map")
            Panel5.Visible=True
            EditTextName.InputType = EditTextName.INPUT_TYPE_TEXT
            EditTextemail.InputType = EditTextemail.INPUT_TYPE_TEXT
            EditTextName.Text = Mappi.Get("vornachname")
            EditTextemail.Text = Mappi.Get("emailadresse")

This NOT:
B4X:
          Mappi = File.ReadMap(share & "/testdir","userdata.map")
 
            EditTextName.InputType = EditTextName.INPUT_TYPE_TEXT
            EditTextemail.InputType = EditTextemail.INPUT_TYPE_TEXT
            EditTextName.Text = Mappi.Get("vornachname")
            EditTextemail.Text = Mappi.Get("emailadresse")
           Panel5.Visible=True

The only difference ist, that in the working solution the Panel5 is made Visible BEFORE getting the values.

Don't know why.....:confused:
 
Upvote 0
Top