I read this question and wondered if the same would apply to my situation.
I want to write accelerometer values (x, y and z) from an Android phone to a database and retrieve it with another app on a tablet to display a graph of the values changing over time. This does not have to happen in real time.
So basically my questions are:
1) can two different applications on two different Android devices use the same SQLite database?
and
2) how do I specify an IP so that the one app on the phone writes to a specified database and the other app on the tablet reads from that same specified database?
I can already read the Accelerometer values and I know how to create a graph, but I'm having trouble with the database component of my project since everything I come across seems to be storing the values on the device's SD card or in a database that is only accessible to the device itself and no other applications or devices.
I've read about specifying a static IP by first obtaining a ContentResolver:
ContentResolver cr = getContentResolver();
then adapting the settings:
Settings.System.putString(cr, Settings.System.WIFI_USE_STATIC_IP, "1");
Settings.System.putString(cr, Settings.System.WIFI_STATIC_IP, "6.6.6.6");
and then enabling the permissions: WRITE_SETTINGS and WRITE_SECURE_SETTINGS.
but I'm not sure where exactly to write this or how to use it correctly.
Please direct me to where I can find some more information regarding setting up SQLite databases and how it can be used by two different applications on two different Android devices?
Thank you in advance.
P.S. I'll update this question with some of my code soon.
can two different applications on two different Android devices use the same SQLite database?
No more than two Web servers running on two different continents can use the same MySQL database. Only processes running on a device with filesystem access to a file can read and write to that file.
how do I specify an IP so that the one app on the phone writes to a specified database and the other app on the tablet reads from that same specified database?
You don't. Android is not a server platform.
At best, you might be able to pull this off if both devices are on the same WiFi LAN, and you write a Web service that exposes a database from one device. This, of course, exposes you to the same security issues that you would have with a Web server, without the benefit of firewalls and the like.
I want to write accelerometer values (x, y and z) from an Android phone to a database and retrieve it with another app on a tablet to display a graph of the values changing over time. This does not have to happen in real time.
Hence, you do not need two devices to access the same database. You need them to work with the same data.
So, you could have the phone send the data to some server via a Web service, and have the tablet retrieve the data from that server via the Web service.
Or, have the phone send data to the tablet via Bluetooth.
Or, if you feel the security is adequate, have the tablet expose a Web service via WiFi that the phone uses (though this really scares me, particularly if the tablet might join some other network, such as by being moved).
In neither case does the phone nor the tablet necessarily even have a database, let alone try to directly share it.
A SQlite database is private to the application which creates it. If you want to share data with other applications you can use a Content Provider.
Although not SQLite, I believe this can be achieved using PouchDB, where you would host one shared remote database which would then sync to two seperate databases for each application.
https://pouchdb.com/
Related
I am experienced with using the WearableDataAPI to synchronize both settings and other game information between Watch and Wearable. In fact, currently certain information gets persisted in the DataAPI which works great until you need to reset the watch or mobile.
I would like to convert to using SQLite to store the data on the Mobile. Is there a way of inserting into a Wearable SQLlite database and it automatically replicating to the Mobile? Or would I need to code the data transmission myself using the DataAPI?
As I know there is now such implementations for common databases.
In my practise, DataAPI might lag while syncing huge (>100kB) files, it consumes battery too.
Use MessageAPI in order to improve the performance for message transfer and create two separate databases on both handheld and wearable using common API.
Or, much better, use only one handheld API and tranfer data from handheld into wearable device using MessageAPI each time when you want to render something on your watches.
I'd like to automatically import my activities from my Garmin Fenix3 into a database (without the need to manually download the TCX files). Two options came to my mind to solve this task:
A Server based app which gets connected to the Garmin Connect API and is notified (via RESTful APIs) by GarminConnect each time an activity has been uploaded - is my understanding correct, that I need for this use case the $5,000 expensive Garmin API licence?? http://developer.garmin.com/garmin-connect-api/overview/
Create an Android App which gets notified by the installed Garmin Android Connect App each time a new activity has been created - how can I achieve this? From my understanding, the Connect IQ Mobile SDK For Android can be used to create an Android App which interacts with your own application on the Garmin Device itself (which is not needed for my scenario, I just want to automatically "download" the activities created by the default Fenix3 apps).
Any help is highly appreciated - thanks.
I can answer now my own question. It is NOT possible to access the recorded data automatically unless you pay the $5,000 for the Garmin API licence (this is soooo ridiculous Garmin!!!). The Connect IQ Mobile SDK approach will NOT do this job, confirmed by the Garmin Support Team.
The only way to get your data is by manually downloading the FIT or TCX file from https://connect.garmin.com . Keep in mind though that the Running Dynamics (which are captured and calculated by the HRM-Run sensor) are NOT included in these files!
Vertical Oscillation
Vertical Ratio
Left/Right Balance
Avg Ground Contact Time
Training Effect
This is a very big disappointment Garmin! In which century are you guys still living? The data generated by the user belongs to the user and it should be easy accessible! Keeping the data locked in your safe will not really attract more users to the connect platform... But time will tell.
I have some questions on android data sharing of multiple devices. Currently, I have a personal project on android application which require multiple device can sharing data offline. You can look at the photo to get more understand about this.
View Image Here
I have a device A running my application which it use for entry data in one activity (entry activity) and device B running the same application which use other activity (result activity). I want the data from device A can be send to device B without internet connection.
For example, when device A entry data and save it. Device B will receive that data. Both devices are in difference room which quite hard to connect via Bluetooth. Both devices do not have NFC.
Does anybody have the idea of this requirement?
Can you give me some advice?
Thanks.
Please try http://developer.android.com/guide/topics/connectivity/wifip2p.html. This might fit your needs. Sample data is also provided there.
I need idea to create a POS solution for multiple counters on a shop in android which will be accessing a single database that can be in any of APK installed on the network or the stand alone SQLite Database.
My Idea is to have a application which holds db and the other application should access that DB.
Is it possible in Android? Please suggest the best possible solution.
Thanks.
SQLite is not intended to be used as a client-server database. It is simply not built for highly concurrent operations. SQLite works well in simpler scenarios as stated here. So, you would probably need a dedicated database server such as MySQL or Oracle that is hosted separately in the network.
If you really wanted to do this, you're going to have to handle any concurrency behaviours yourself.
However, your best bet is to do exactly what you've said:
One (master) device holds the database. It accepts signals from the other devices, and allows them to (potentially) query (or alter) the database's contents.
In order to do so, you'll need to handle:
Some means by which the devices will discover the master device. In Android 4.1 there is a Network Service Discovery API for this: http://developer.android.com/training/connect-devices-wirelessly/nsd.html The master device would advertise the service to the others.
The devices might be able to use this Peer-to-Peer API to communicate: http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html
Once you've established a connection, you'll also need to create a vocabulary of commands which the clients can send to the master device, and a means of dispatching those requests.
This specific case does seem like it might be better suited to having a "real PC" acting as the hub with a more robust application stack (e.g. Postgres or even MySQL, more options for network server tools and administration, faster/more storage options, et al.)
I have developed an application in Android using sqlite database.
The data in database related to application should be same in different mobiles,if many mobiles are used.
Is it possible to sync the database data of particular application istalled in different android mobiles using Wi-Fi?
There are a number of ways to solve this. All depend on more details in your app. Are you wanting immediate or eventual consistency? Are the phones close or distant? Is it assumed that all the communicating processes are always running? or at least running simultaneously?
You could:
a) connect the processes via sockets if the IPs are all known
b) write to a central DB and have timestamped data that each phone would update to if necc.
c) connect via bluetooth assuming close proximity
You need to provide more details. I don't think sqllite supports replication if that's what you're asking. You'd need to provide your own solution.