Android Question Updateable config file for B4A app

AKJammer

Active Member
Licensed User
Hey all, I'm hoping this is possible.
I have an android app that connects to a MariaDB database via JRDBC2. The problem is that where I do the development and testing here at the house, the IP address of the server and database is different than the IP address where it is run in production. I use a variable to set the location:

Private const rdcLink As String = "http://192.168.1.222:17178/rdc"

In the past I've recompiled with a different string when I get to the production location, but then I have to scramble to get my app reinstalled on all the tablets.

I'm trying to find a way to read a readonly (by the app) config file that I can set from outside the app using files or something to copy the config file to the correct location.

Is this possible? Or is there another way of doing the same thing?

Thanks,
Jim

Merry Christmas!!
 

AKJammer

Active Member
Licensed User
Thanks Erel, that'll definitely work. I had another idea in the middle of the night. I can control the final octet of the IP address, just not most of the subnet information. So here at the house it's 192.168.1.xxx, while it may be 192.168.7.xxx or 10.0.3.xxx at the event. But I can always make sure my final octet is 222 (xxx.xxx.xxx.222). So I think I can just get the IP address of the tablet, strip off the last octet and replace it with 222 and that should get me my database server. I'm going to see if that'll work. If it does I'll post the code I use. If it doesn't, then I'll use ContentChooser.

Thanks again,
Jim


Update:
Yeah!! that worked. Here's my code.

B4X:
Sub Process_Globals
...
    Public rdcLink As String
...
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Public server As ServerSocket ' Needs the Network library
    server.Initialize(8888, "")
    Dim myIP As String = server.GetMyIP
    server.Close
    Dim subnet As String = myIP.SubString2(0, myIP.LastIndexOf(".") + 1)
    
    rdcLink = $"http://${subnet}222:17178/rdc"$
    
...
...
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…