Handling sqlite in a local network of android devices

mc73

Well-Known Member
Licensed User
Longtime User
Hello,

My app is handling an sqlite database loaded on a device. At the same time, I have the same database loaded on another device. Now, I know that the use of mySQL could be a solution, but since I find sqlite sufficient for my app, I chose to send data from one device to the other and then let them update their table records.
My question is this: if I have two or more 'clients' and they send data at the listening 'server' at the very same moment, the routine provided by Erel at his very useful network tutorial (thank you!) will handle the multiple requests properly or perhaps I have to create another server socket with different port for example, in order to avoid conflicts? Thank you.
 

mc73

Well-Known Member
Licensed User
Longtime User
Hello Erel and thank you for your reply. I will surely move to Async, I think this is the best as suggested.

I am not quite sure I follow you on this, since in my case I have 2 'clients' and 1 'server'.
I connect from clientA to server, by using your recommended code:

Socket1.Initialize("Socket1")
Socket1.Connect ("xxx.xxx.x.xxx",xxxx,20000)

Then the socket1 event is raised, so I am sending data:

If Successful = False Then
Msgbox(LastException.Message, "Error connecting")
Return
End If

Dim sb As StringBuilder
sb.Initialize
Dim tr2 As TextWriter
sb.Append ("something")
Dim s As String
s=sb.ToString
tr2.Initialize2 (Socket1.OutputStream,"PrefEncoding")
tr2.WriteLine (s)
tr2.close
Socket1.Close

Now, what if at the very same moment, clientB sends data? Server is listening so it will handle both requests without a conflict? This thing is very important to me, since for 'server' I have a network printer and also another android for updating db records.

(By the way, I've noticed that 'successful' is always true, even if my 'server' is out of order, but I think there is a thread dealing with this, so I will check it out very soon.)
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Exactly. Two (or more) android devices, connecting to a 'server' Android device which stores all separate db records.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Thank you very much for your reply, I am on to checking the stability of my code and I hope it goes well :)
 
Upvote 0
Top