Possible to automatically sync SQLite from Wearable to Mobile? - android

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.

Related

data exchange using sockets best option?

For mobile development i woud like to move something on the screen on a mobile device and on another mobile device you see the same object moving.
What would be my best option to use to exchange this data? I thought about firebase but the problem is you move the image alot of times so you easily get to the 50000 limit within an hour. also the fact that saving an position is abit odd to do in a database.
My second option would be using netty framework. I thought about using their socketstream option. My question about this is, my school stresses the use of an api between data exchange but is that also possible here? or is that more for webdevelopment?
In summery, What would be the best option to use for data exchange if you need to send alot of small request. If you sockets/nio framework is it normal to put an api between the client and server?
I thought about firebase but the problem is...
You don’t need a database because you don’t want to save the object’s position. This data is not valuable to you (right?).
You need to pass data from one device to the other to see the object moving. This can be done by establishing a network between these two devices. This can be done using sockets.
If you sockets/nio framework is it normal to put an api between the
client and server?
If this API use sockets under the hood to simplify a client/server implementation for example then it’s not a good idea to use sockets. They’ve already being used by the API.
On the other hand if the API does need socket implementation from your part to be used correctly, like the android Bluetooth API, then yes it’s normal.
Your use case
You can do this by connecting the two devices on the same network and transmit freely any data you like.
If this network doesn’t need to be the Internet then you may want to transmit data over
Bluetooth
WiFi p2p
or your local WiFi using NSD
For these and more see Android Connectivity.

Android wear stream accelerometer data to handheld

I an new to android wear app development. I wanted to create an app which streams accelerometer data continuously from wear device to handheld, and do some processing on my handheld. Does anyone know how can I do it?
I went through that pain recently. Try this link (a lot of base code required)
https://developer.android.com/training/wearables/data-layer/index.html up to the syncing data items page
Essentially, the data-api makes a shared dictionary that fires an event when a field is updated. Unfortunately the bluetooth connectivity seems quite slow. My current workaround is to increase the sensor delay and only update if the change is fairly dramatic.

Send accelerometerdata from wear to mobile

I am looking for the best way to send accelerometer data from my Android Wear device (20 entries per second) to my smartphone. The exchange should be as fast as possible to create a nearly real time XYchart on the smartphone.
What is the best way to send my data? Does MessageAPI provides an exchange which is fast enough?
You need to use either the Message or Data API. SharedPreferences aren't automatically "shared" between devices (such as a watch and a phone).
Also, be realistic about data transfer rates. You'll get accelerometer data on the watch at a much faster rate than you can realistically send it to the phone, and will need to handle that discrepancy. It might be that you want to use the Channel API instead - but that will require repackaging your ArrayList into a Stream.

Is there any possibility to sync sqlite table data between two android mobiles using wi-fi

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.

Can two Android devices, running different applications, use the same SQLite Database?

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/

Categories

Resources