Android Shared Database - java

Hello I've been trying to develop an app for android dor retail system where for instance there would be a total of 5 tablets in a restaurant all running my app but since in my country retail software must follow a strict number of rules, i cant put a database on each android.. they will have to have a way to access the same database over LAN, bluetooth or other.. I developped a test app with a WCF web service and client app in android but apart from the fact that i have a dynamic IP so i would have to be configuring the connection every time i restarted, it's not very reliable
If somebody could point me in the right direction.. i've been googling for the past week and nothing..
PS: One more thing, this system (retail system) is to be implemented in a number of locations so if possible i would like to make only LAN based connections.. Thanks

http://en.wikipedia.org/wiki/DynDNS use something like this, you will have an ability to use the same DNS name updated each time you have new ip.
As for reliability, you need to track the reason first. Try to ping the server for some time and gather statistics.

Related

Can an Android app create a local sessions that others using the same app can connect to without a need of an intermediate server?

I am totally new in android development and wanted to create this app that will keep score of a darts game. I want to create a private session and only people with the ID can join, everybody inputs their score every round individually using their own smartphone and the person who created the session is hosting the server and all the calculations and score tracking is hosted on that persons device. Is that possible or is an intermediate server a must?
You can use Wi-Fi Direct for that - it's a P2P network with a "group owner".
Here's the relevant documentation.

Host database using Android phone

Here is the current scenario:
I have two(2) Android phones.
Android Phone 1 as the server phone.
Android Phone 2 as the client phone.
Here is what I want to do:
I want to create an Android-based app (E.g. Student Information app) where it will have basically two (2) modes:
Server - for adding, editing and deleting data on a local database.
Client - for viewing data from the database of the server.
The app will be installed to Android Phone 1 and set to Server mode.
The app will be installed to Android Phone 2 and set to Client mode.
I want to ask these questions:
I want to locally host the database of the Server app, so that Client app will be able to view the data. Is this possible?
If yes, how can I do it?
Note:
I am currently a web developer so I know that connected on the same network is a requirement.
I have implemented the same concept on a medium business where the web-based system is locally hosted so that computers on the same network can access it.
Suggest everything that you want to suggest, except the disadvantage of doing this concept. I am aware of some obvious disadvantages based from my research and willing to face the disadvantages provided that I will be able to implement the concept.
Rooting the phones is an option.
I want to accommodate small-sized business that is why I want to use Android phones rather than using Desktop Computers/Laptop.
I have read similar suggested questions here based on my title.
We have done the exact same thing in my company. The way we solved this is that the server exposes a service using the Android NSD API, so the clients (using the same API) can find it on the network. And after a client has connected to the server, the server sends its database file (yes, the .db file in /data/data/...) to the client via OutputStream. When the client receives the entire database and checks for its integrity, it copies it to its own /data/data/... and restarts part of the app.
Android NSD

How to implement client server in android for making BINGO game, but not for chat application

I am making a game of Bingo. For that I will be connecting two mobiles via wifi- hotspot and the grid should be shared to both clients, that is both mobiles should see the grid. How can i pass the grid two both clients? Also, how to pass numbers in between client and server? Via object or other thing and how? Also how to exactly implement client server application making 2 java files n android? PS: we are not implementing a chat application.
Bingo XML file: https://github.com/TanishaShrotriya/SDL/blob/master/activity_main_bingo.xml
Java File:https://github.com/TanishaShrotriya/SDL/blob/master/MainActivity_bingo.java
You have a few options. First you need to determine which architecture works for you.
Client/Server (AWS Instance with APIs, and Firebase with PUSH)
---This will enable the devices to get current came status on open, and push changes to their board on confirming their space was called/filled.
---This will enable other devices in that "room" a name given to a virtual shared space for a game. To receive PUSH notification of changed data to display.
Next you need to decide if the server will maintain the full state of each user or just the current called values for comparisons.
If you decide that you do not want to write APIs and setup a Server for PUSH, you can do an ad-hoc wi-fi or even a BLE based communication among everyone in the area. However, this will require significantly more understanding of how to pass bytes, handle network issues, latencies, and communicating from device to device.
If you choose to do the ad-hoc wifi as you mentioned you would have to maintain a ton of connections like a mesh network. A better option would be to have all devices join the same wifi network so that they have access to each other, but aren't necessarily keeping track of mesh networking.
However, even if you are on the same wifi knowing who to send the information to can be difficult without a server to retain routes and IPs of current players. So you may have to create a host so that it can listen for enrolled players. The host device would need to retain routes to all other devices so that it can send the info to each IP address when a change occurs.
I still highly recommend going the client/server route of APIs and PUSH it will be far more reliable.
Now as far as how to pass the data, you could of course screenshot via code and send images, but that is wasteful. I would recommend having a matrix that keeps track of the values covered and simply send a JSON snippet of the card_id, the player_id, and the json of covered blocks to the server that can then push changes back to all players in the "virtual room". This allows them to see how their fellow competitors are doing.
So I would have to ask for more details about what your goal is to help any further, but that is my recommendation, because ad-hoc wifi or bluetooth is doable, but on a mesh scale size you will have a giant headache on your hands. The host scenario device with all on same wifi would be my second direction if you are really anti-server and APIs, which the only reason I could see you avoiding that is if you wanted to play off wifi that doesn't have internet or if you don't want to pay the $30/month for traffic while it is small.
Let me know if that helps or if you want to provide additional clarity.

How to share database between same application in multiple devices without server

I have created database in one application and that application is installed in multiple devices.My requirement is that if i change the value in database of one device then,that changes in database should reflect in another device of same application.I need it without server/third api.
Thanks in advance...
This is precisely when one does need a sever.
Stop and consider what it is that you are asking for. You need a way for a phone to notify all other phones that hold the same application about a change. Phones are not directly addressable to each other via the web, which makes any kind of peer to peer algorithm tricky. SMS texts is the closest form of direct addressing that phones do support, thus it could be used to build a peer to peer protocol, but that would be tricky, unreliable and is unlikely to be beneficial.
A server on the other hand is the standard approach to solving this problem, the server acts as a shared agent that all phones that connect to the web can address easily. Even if the server is just an FTP server on a freebie hosting site.
You need to implement a server functionality in your android application.
What is a server : A server is a running instance of an application (software) capable of accepting requests from the client and giving responses accordingly. Servers can run on any computer including dedicated computers, which individually are also often referred to as "the server".
For further information,I would like to provide this link which will clarify you about communication between two devices Android - communicating between two devices (Use of bluetooth etc.)

Running java server application 24/7 and secrets behind all those famous online live apps

I'm currently building an application that is about VOIP / random chatting, which is similar to skype or chatroullet. My question is extension to this
https://stackoverflow.com/questions/11384155/running-java-server-application-24-7-not-on-local-machine
I've been experimenting and playing around with TCP / UDP sockets and now I have ability to build VOIP / instant chatting applications. But as you might already know, in order for data transmission between client to client or client to server, the server application has to be powered on (in other word, be online) and be accessible by client applications. The problem is that, I'm not living by my self but with my family, which I can't simply use one of my computer to run my server application for 24/7 mainly due to the electricity bills and my lack of knowledge about the networking concerns me about the security, because I had to go through some configuration / port forwarding on my current router in order to make the protocol accessible by other users outside of my local network. So my biggest question is that, how do people or developers normally have been dealing with this kind of situations? Have they been simply using their own computer to run the server application? or have they purchased an external machine to run the server application
===========================================
Additional question:
Is TCP / UDP socket the only way of making applications such as MMO, VOIP and instant chatting programs?
i see that your topic was closed in the previous thread. I think such questions are unrelated to stackoverflow.
However, i would like to give you a glimpse of what is happening to most of us who own / make Java Web Applications. I used to work in a datacenter for a year and a half. Java applications are a little harder to put online as they require resources that not many data centres are willing to invest time and support in. Other than that, they are pretty much as straightforward as normal PHP applications.
You will need the standard options like Colocation, Dedicated Server, VPS, Cloud Virtual Machine, or a shared tomcat / application server hosting.
Colocation is where you put your own purchased and configured server with the data center, you have complete ownership of the server, nobody can touch it unless permitted by yourself. You pay to put your server into the data center, and are in charged of anything that happens within the server, including OS patch.
Usually servers in data centers (due to size constraint) come in rack units. 1U refers to 1 rack space, usually this is equivalent to one PC, although a server is much more powerful. In Singapore, the charges per U is SG$200.
Dedicated server is where you lease a server from the data center. The server is managed by the data center and can be as powerful as you want it to be. OS updates, installations, service guarantees are provided by the data center.
VPS is having a fraction of a server resource, but many challenge that you do not have the "root" access to the server in most cases.
Cloud is the virtualization of the entire operating system. If this was Linux, you would have the root access to it. Many of us now are going for this option because of its scalability. Some data centers may use popular virtualization hypervisors like VMware ESXi, Microsoft Hyper V.
The list above is represented from the most expensive to the least. Of course, that is depending on your location and service provider.
Hardly anybody i know tries to put a running server at home, it is a fire hazard itself, you will not know when your electricity will be cut off, standard dedicated bandwidth would as expensive.
Hosting with a data center would be much cost efficient and safer in my opinion.
EDIT:
Is TCP / UDP socket the only way of making applications such as MMO, VOIP and instant chatting programs?
Have you looked at HTML 5 Web Sockets, or any AJAX based framework for this?
Try searching the web for cloud hosting. For example, Heroku, AWS and many others provide a hosted service. That is what people use to host their service and it is more cost effective than trying to maintain something yourself.
Are you writing an Android application for it as well? Just as an aside you might want to make use of this ARO tool to ensure you are using the network efficiently. http://developer.att.com/developer/legalAgreementPage.jsp?passedItemId=9700312

Categories