IBM Worklight SQL adapter for real device - android

If i use local database, say MySQL, it works perfect on simulator and emulator but for real device, localhost won't do, So i tried online database hosting.
When using online hosting from www.freemysqlhosting.net, i had setup the database in my database development perspective in Eclipse using the provided id and password, so it worked well on my simulator, emulator and real device that was connected to the same network as that system on which that database was setup, but for any anonymous device,it failed!
Then i tried with sqllite, again it worked with simulator and emulator but for real device,it showed UNRESPONSIVE_HOST error.
My question is: if i want to develop an app using IBM Worklight that uses some database and want to distribute it, how can i do it?

It would have been far far more helpful if you'd just provide the error log from LogCat...
When using Android, it is a good practice to not use localhost, instead to use the actual IP address. See this question: IBM Worklight - Unable to connect to database when using IP address instead of localhost
MySQL is a server like any other server; if you want to use it outside of your private local network, then you simply need to open it to incoming connections from the public Internet. This is not something a developer needs to fuss around with, that's what IT departments are for. So google and see how to open your network.

This sounds as though you are trying to access a database directly from your device. Is that the case?
I would strongly recommend using Worklight Adapters here. So the pattern goes:
App on Device ---> Adapter ---> Database
In that pattern the responsibility for getting from Device to the Adapter lies with Worklight and hence should be completely unaffected by whether it's a real device or an emulated one, and should also be independent of what particular database you are using or where it it.
The hop from Adapter to Database is something you can set up and test without even having an deployed anywhere. Just use the test environment in Eclipse to call adapter methods.
Why not go from device directly to database? In general that's a really bad security pattern, you're effectively putting data you care about in a very hackable place. Also it will not scale well to large numbers of users: connecting directly from the device means that effectively every user has their own connection, going via the adapter users share a controllable number of connections.

Your problem is not with the SQL server it is with the connection between the device and the Worklight server. You need to be able to connect from the device to the Worklight server. Open a browser on the device and point it to the Worklight console and see that you can access it.

Related

best way to connect android app with desktop app?

I want to develop a system in which data is being shared between DESKTOP app and Android app.
After searching I have found that I need a server in between them. But I can't figure out what the server is? How do I create it? And how will it help me connect my two platform devices?
Desktop App will receive data from android app. And manage data. It will also be used to send notifications/messages to android apps.
Android App will be used to input data and send it to desktop app. It will receive updates/notifications from desktop app.
Now how do I connect these two? I basically need a common database for real-time data sharing and notifications.
Edit: I am building the desktop app using C# and android app using Java.
Edit2: Maybe I can host the database on CPANEL or 000webhost using PHP. And then connect it with both android and C#. Is this the correct way to do it? Is it possible to connect it with C#? I know it can be connected with Android, not sure about C#.
You don't necessarily need a database. You need a common network protocol between two applications.
All network communication is done via sockets. You need a library that allows you send data over sockets. For example, here's an Android guide that is about sockets.
A socket binds to a specific port of a computer, essentially making it a "server". Much like how web servers all expose port 80, and communicate over a protocol called HTTP. Which is important because it is up to you to decide what protocol your applications communicate between each other, because the socket just sends bytes - it doesn't care what you send or how, as long as it travels to a port on a particular server. It also won't parse the data for you, that's up to your application to handle. For example, how would your desktop app know the Android device sent it a text message, or some image to be displayed, or an address to show a map?
All in all, your reason for wanting a desktop application rather than a web application is not entirely clear. Parsing only the body of HTTP payloads from different HTTP paths that are mapped to different methods (which is typically referred to as a REST API) is much simpler than building your own protocol. You might as well build a desktop GUI over top of a web server.
Making the desktop app send updates back to your mobile application is basically impossible using a bi-directional socket architecture. Your Android should not be running an open server socket continuously just for your application, mostly because battery drain, but because its network address is subject to change frequently, and you therefore additionally need a registration server from which your device would reconnect to. Such a service exists as Firebase Cloud Messaging, which is a rebranding of the GCM technology made by Google, and it can be used to send push notifications to devices, but only with small data payloads.
See here about what activities occur on an Android device for notifications. How does push notification technology work on Android?
Back to the question about databases. Suggesting one to use is too broad. And you only need one of those if you want to store and/or query or join datasets. The same computer running the desktop app can install and run whatever flavor of database you prefer, whether it's a relational database or noSQL database, entirely up to you. The only realtime databases I know of are RethinkDB and Firebase.
You could also just hold a SQLite file which is as good as a small scale database (even the SQLite documentation recommends it for low traffic web sites).
Firebase supports web interface, so you can develop html code and integrate in desktop app, something like web integration in windows form application

Is it possible to remotely run queries to a database on a device through a web interface?

So far I think it's a security thing that you're not allowed reading/writing to an Android SQLite database outside of the containing app's process.
But are there advanced techniques or tools that can be used to achieve this?
For instance, I want to make a web interface with a textbox where the Android app would connect to and then I can run SQL queries via said interface to read the database or to insert records into it.
I'm writing this question because I'm really stumped. Usually my search gives opposite results which is accessing a remote database with an Android app.
You will have to develop an API backend. The mobile app ( client ) will communicate with the API and do the desired operation based on the response.
It's not possible to directly connect to the app sqlite database. You can send web request and get the info you want, handle it in your app to store it in the sqlite database
You will have to add security measures, so everyone can't access your API.
So far I think it's a security thing that you're not allowed reading/writing to an Android SQLite database.
Apps can read and write to their SQLite databases. Otherwise, the database would not exist.
I want to make a web interface with a textbox where the Android app would connect to and then I can run SQL queries via said interface to read the database or to insert records into it.
You are certainly welcome to embed a Web server into your app. For example, Stetho does this to integrate with Chrome Dev Tools, offering your SQL interface among other things.
However:
Doing this for anything other than a debug build of your app is very risky, as securing a Web server is difficult enough when it is on a traditional server environment, let alone an Android device
The Web server is only accessible by whatever can reach the device via an IP address, which means it's usually only useful on WiFi (where it could be reached by other devices on the same WiFi LAN segment)

Use MS Access form on a mobile device

I'm going to a robotics competition (FRC) in which we're supposed to "scout" other robots' and see how they perform. My database consists of the number of points they get for each category. I made a form to enter in the data. There are six teams, and I wanted to use six android phones or tablets for data entry.
Is there a way to open the form and enter data in on a mobile device, and then transfer the records to a master computer?
P.S. At the competition we would not have an internet connection, so the only data transfer methods would be USB, Bluetooth, or LAN.
Thanks
EDIT: I figured it out. Instead of using an access form, i'm creating an android app that simply allows you to enter the data in, and export the data as a csv to use in a database. I'll try and make it work.
The easiest way to "run" MS Access application on any iOS, Android or WinCE device is using remote desktop. Enterprise solutions like Citrix would be better. You will need a server in local network, which can support the terminal clients and install on each device RDP terminal client or Citrix client. Access application in fact works on the server, mobile device shows the screen and allows to interact with application.

How does Web Service works in Android

I'm studying android and I have a question. How to transfer data between app and client ? which DBMS I can use ? and how to make my laptop become server ? all of this I just want to practice. Thanks for all advice !
you need a server program which service requests via web services. So this is the server program which has access to DB and choosing DBMS does not depends on android app. when your server program reads data from DB, it'll send them to android app in JSON or XML format (most common formats).
you can setup a local network in your laptop and connect you cell phone to that. but for testing purpose you can use emulator in your laptop.

Syncing between a local network and Android application

I am in need of some help here.
I want to make an Android application that eventually syncs to a web server in order to get information (i.e. user can write a note through the website, and it automatically syncs to the phone).
I am aware that I would need some web servers and hosting, and don't know too much about that so I will look into it later.
MY question, however, is how I can simulate this over a local network?
As in, if I create a basic webpage that has a two text boxes (one for name, one for content) and a 'submit' button, if I run it via localhost WHAT methods can I use to get this information to sync to my handset?
If anyone could be kind enough to give me a laymens terms breakdown it would be seriously appreciated, I feel so lost!
You have some alternatives to achieve what you want, here is a traditional one:
Start with installing XAMPP and run a local server
Write your web pages, store the data in mysql
Write PHP code to extract the data from mysql
Use Android HttpClient to call your PHP
There are other alternatives:
Use the same method but instead of PHP write HTML5 and you have a mobile WEB application
Check out the GCM Demo Application
Check out Google App Engine
Check out Amazon Web Services
There are others
Enjoy :)
Yaron
When you use localhost (meaning you install a server package such as Apache / IIS / XAMPP / WAMP in your computer), your machine becomes a server. So, you can access the localhost from any device which is in the same network.
Say you have a computer connected to a WiFi router. If you setup the server i.e. the localhost in that computer and a laptop and a mobile phone is connected to the same WiFi router, the phone and laptop will be able to get service from the computer.
To access data stored in the MySQL server from the other devices (e.g. the phone), you have to write proper service. Else, you can write a mobile web app in the server that accesses the MySQL data and just access it from the device.

Categories

Resources