Theme : Newspaper updates in android application.
How to fetch or retrieve data from server and post updates on android application . How to manage offline storage means whenever there is no internet connection how the data gone be updated on android application , atleast how it consider showing updates on android application . If any one known this issue please answer about it .
I am actually using php or json as intermediate files for fetching data from server and send updates to android application but its seems to be more complex and if i wont get the permission to access the server side files , how do i manage for updates ? whether is it necessary to have permission to access the server files ?
More about the topics : if i want to syncronise the update with website , how do i handle it or implement it ? i am not asking any sort of coding here .
How to fetch or retrieve data from server and post updates on android application
use HTTPClient.
How to manage offline storage means whenever there is no internet connection how the data gone be updated on android application
I think you don't understand what offline storage means. If there is no internet connection, that's it. You are not able to update your content. Offline storage is useful if you have internet connection, but not everytime. The content you downloaded when you had internet connection can be saved to SQLLite to be loaded when you don't have internet connection.
I am actually using php or json as intermediate files for fetching data from server and send updates to android application but its seems to be more complex and if i wont get the permission to access the server side files , how do i manage for updates ? whether is it necessary to have permission to access the server files ?
Create WebService as an interface. Do not let other system to be able to directly access your files. Or just create a PHP files that basically return Json or XML Data.
Other option : create an RSS.
More about the topics : if i want to syncronise the update with website , how do i handle it or implement it ? i am not asking any sort of coding here .
Create an event to start sync using HTTPClient. If there is new update, save it to SQLLite(for offline storage) and display the content. The event can be triggered during the start of your application or clicking refresh button and if Internet exist.
Update :
There is a new framework called couchbase mobile. You can sync the local mobile db from a couch server. You can insert/update the data locally(offline mode) and then the data can be synced also to the couch server, whenever you have internet connection. This means the need to create HTTPClient is no longer necessary.
For the database, try cloudant.
Related
I am planning to make a software which requires two or more databases to be in sync with a main server database ( located on a web server ). Suppose one user have installed my software on more than one computers. Suppose he updates some info on PC-1 then the change should be locally updated and if he is connected with the internet, it should get in sync with the main web server. When he opens the software on PC-2, latest into must be shown there ( assuming he is connected with the internet ).
Now suppose both PC-1 and PC-2 have same data, and both are offline. User deletes the data from PC-1 but don't deletes it from PC-2 ( he assumes it'll get managed automatically ), now when both of the systems go online, the record must be deleted from PC-2 too.
Basically, I am trying to find the database which was most recently updated or modified and sync it with the main database ( on the server ). How can I do it ?
It sounds like you want to synchronize some user data whenever the users or application becomes "online" again.
A couple of suitable services are:
Amazon Cognito Sync is an AWS service and client library that enables cross-device syncing of application-related user data. You can use it to synchronize user profile data across mobile devices and the web without requiring your own backend. The client libraries cache data locally so your app can read and write data regardless of device connectivity status. When the device is online, you can synchronize data, and if you set up push sync, notify other devices immediately that an update is available.
AWS AppSync enables developers to interact with their data by using a managed GraphQL service. GraphQL offers many benefits over traditional gateways, encourages declarative coding style, and works seamlessly with modern tools and frameworks, including React, React Native, iOS, and Android. GraphQL is a data language that was developed to enable apps to fetch data from servers. It has a declarative, self-documenting style. In a GraphQL operation, the client specifies how to structure the data when it is returned by the server. This makes it possible for the client to query only for the data it needs, in the format that it needs it in.
I am developing an app that uses a database to store the data on the server, but I am trying to save some of the data locally, and in the event of no internet connection being established, save new data locally to the device and synchronize any changes to the server when an connection is re-established. What is the best and most efficient way to do this?
I have been looking at Androids Room persistence library and it seems like the logical choice, but I am not sure how it goes about synchronizing changes to/from the local storage database. I have looked at multiple threads and forums for help, but have had no luck so far. Please help.
One way is to build your own sync adapter: https://developer.android.com/training/sync-adapters
You will need to handle most of the sync logic between the client and the server, but that allows you to use any database technology in the server. From the docs:
A sync adapter doesn't automate any data transfer tasks. If you want to download data from a server and store it in a content provider, you have to provide the code that requests the data, downloads it, and inserts it in the provider. Similarly, if you want to send data to a server, you have to read it from a file, database, or provider, and send the necessary upload request. You also have to handle network errors that occur while your data transfer is running.
A sync adapter doesn't automatically handle conflicts between data on the server and data on the device. Also, it doesn't automatically detect if the data on the server is newer than the data on the device, or vice versa. Instead, you have to provide your own algorithms for handling this situation.
Use firestore and enable offline data persistence. https://firebase.google.com/docs/firestore/manage-data/enable-offline
So I got a simple app with a sqli database,
the app just shows the content which is saved in the database.
So if I am correct the sqli database is saved inside the app (apk),
what I am questioning myself is if I do have repeatedly upload the app / apk if I change, delete or add something in the database.
If yes is there a way around this, to like get the data from a database without repeatedly uploading the application if data has changed.
Yes, if you change something in the database you need to upload the apk, because the database is inside the apk. The alternative would be to put the database on a server. Then you would write a back end for your app in your language of choice, and this code would access the database. You could also use a Back End As a Service. Google BAAS to get info on the available options.
I'm new to android sync so I really need ideas to get started. Actually my app's requirement is like this: My app needs to connect to my database online. But my android app can be used offline meaning, the user can add records to a local db, say sqlite. And then when the user connects to the Internet, the app should automatically connect to the server and add the record the user added when he is not online. Can you give me some considerations and ideas on how to do this? I really need your help guys. Thanks.
I will recommend you to go for Sync Adapter. See these links
AbstractThreadedSyncAdapter and Creating Sync Adapter.
I have used them long time ago. I will say that it is the best approach for syncing data between device and server. Usually, email apps use these sync adapters.
Sample is also given there. Download it if you want to go deep inside of "HOW".
Thank You!
You need to run background service like android alarm manager. You need to check that device is connected via internet or not. if device is connected via internet then sync the data to server.
Check this like to the way of data sync
How to sync SQLite database on Android phone with MySQL database on server?
Thanks
I am new to Java and Android. I am just beginning work on an app that will save information to a server that someone else from within the same company can retrieve using the same app from a different android device. I know how to simply store data on a server using simple php scripts but this is a bit more complex and involves one user writing information to the server, while another user can see / download it. Within a company there would be multiple users who have acceess to this data. So my question would be, whats the best way to implement a company-wide database that ONLY members of the same company can have access to? Sorry if this seems obvious to some of you. I am just getting started and I have 7 books on android programming and none of them describe how to do quite what I am trying to do.
To do this you need to use Android network services to access data. In other words to retrieve a networked database information your device will connect to your service with a specified URL and arguments. In turn, the service will reply with the required data, say may be in XML format. All your app needs to do is parse the XMl and display the date as desired.
Same thing applies to putting data into the server, in this case however the data will be sent as arguments to the network service URL and the service will handle the persistence to a database.
My advise is to do a Google search of the keyword "Android Network Services".