How to use Room with multi FirestoreRecyclerAdapter? - java

I'm using 4 RecycleView in MainActivity which load data from Cloud Firestor using FirestoreRecyclerAdapter. Now I want to use Room to create receipt for the user in ReceiptActivity.
I did all staff, but there is something wrong when I try to delete and update item in Room. My app is crashing, so I'm asking if there is conflict with what I'm doing or not? If not,please guide me with best practice to do that. Thanks in advance.
Error message

When using Cloud Firestore, offline persistence:
For Android and iOS, offline persistence is enabled by default. To disable persistence, set the PersistenceEnabled option to false.
Which means that Firestore will create a local (internal) copy of your entire database on users device. So the same thing that you want to get can be also achieved without adding an extra local database because by default is one that already exists.
Furthermore, if you need to get the data from the cache only, you can achieve this with the help of the DocumentReference.get(Source source) and Query.get(Source source) methods.
By default, get() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. This behavior can be altered via the Source parameter.
So we can now pass as an argument to the DocumentReference or to the Query the source so we can force the retrieval of data from the server only, chache only or attempt server and fall back to the cache.

Related

Is there a way to wait for the completion status of a transfer?

I am creating a S3 transfer to Big Query using Java and Google's Big Query Data Transfer package. My steps are:
Create a TransferConfig with my S3 details/permissions
Create a DataTransferServiceClient
Use steps 1 and 2 to create a TransferConfigRequest on Big Query
Create and start a StartManualTransferRunsRequest using the TransferConfig details
WAIT for transfer to be completed, then do additional things
I'm unsure how to approach step 5 and whether or not the Big Query Data Transfer package has a way to return a status once the transfer is completed. Does anyone know a recommended way to solve this issue?
Based on the public documentation that Google offers, you could create a cloud monitoring alert following these steps:
In the Cloud Console, go to the Monitoring page.
In the navigation pane, select Alerting > Create policy.
Click Add Condition and select a condition type.
4.Select metrics and filters. For metrics, the resource type is BigQuery DTS Config.
Click Save Condition.
Enter policy name, and then click Save Policy.
Here you can see more details on how to correctly define cloud monitoring alerts.

Android database and connection to the cloud

I'm developing and Android app which provides content to the user.
I want to store the information of the data in a database on the cloud and locally, and to store the actual content also on the cloud, and access it via the information on the database.
I also want to be able to show the user content based on a date, and to check for that frequently.
I would also like to be able to update the content over the web, and show the user news and updates on the fly.
I'm new to this, and would like to understand this. I read all sorts of terms, but not sure which I need for what. GCM, Content Provider, SyncAdapter, database, AsyncTask, etc..
If someone could please give me an overview of how to do what I want, with an explanation, I would be very grateful.
Thanks!
I want to store the information of the data in a database on the cloud
and locally, and to store the actual content also on the cloud, and
access it via the information on the database.
About this requirement, I recommend you can use Azure Offline Data Sync feature to sync up your local and cloud data. Please refer to this documents:
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-android-get-started-offline-data/
I would also like to be able to update the content over the web, and
show the user news and updates on the fly.
Notification Hub Service is for pushing the message to client and customer, if you want to use the similar feature, please refer to this documents :
https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-push-notification-overview/#integration-with-app-service-mobile-apps

Can I set the ObjectId in Backendless manually

I use Parse.com for storing my data but since they will shut down their service I am going to use Backendless in the future.
I use it in my Android app for syncing my data between devices. Since the app can work offline I will use a SQLite DB to store the data and sync it to Backendless when online. And new data from Backendless will be stored in the SQLite DB as well to be available when working offline.
So when offline and creating a new record, I have to store it in SQLite until being online again. Now can I set the ObjectId, which is the identifier of Backendless objects, manually and will Backendless still get that is has not been saved to the cloud even already having an ObjectId set?
Even if the backend accepts an external objectId (and I think it doesn't), it's safer to just drop the local ObjectId before sending the objects to the backend, and let the backend generate a new one. This way, you won't have to manage several ID generators and worry about unicity.
If you can't change the local ObjectId, you can still delete and re-create the local object with the backend Id.

Parse.com: Deploy app with local DB

I use the Parse.com Cloud service in my Android app to sync data between devices.
I use the app mainly offline and use the local DB
Parse.enableLocalDatastore(getApplicationContext());
I want to deploy my app with a local DB that already contains a few thousand records. How can I do that? I don't want to sync the data on every device on first use.
Local datastore is not really a "local db", although you get some of the benefits a local db would give you. There is unfortunately no way to pre-populate the local datastore like you're after. The only way I can think of is to use another technology (like sqlite/core data etc) to store the pre-populated data. The problem is that to pin the data to the local datastore, you would need to get the PFObjects from Parse first anyway...
The Parse local datastore is not created to work as an offline database per se; only to offer an "offline mode" for your online data.

Simultaneous access SQLITE JAVA SERVICE / CordovaJS APP errors

Aloa
I am trying to make an app (Android to begin, and then IOS) that one side (JAVA) executes SQL statements on a database stored on the phone (imported once from the www folder and using SQLiteOpenHelper ..) in java from a background service starting at the boot. No worries on that side.
On the other hand (CordovaJS) I check / update the same database from the same application, but in the GUI (webview) via the cordova Cordova-storage-sqlite plugin. No worries either on that side ...
But when JAVA and CordovaJS try to use the database at the same time, the app crash sometimes...
How can I do to access to the base of both sides simultaneously?
Otherwise what would be the best solution:
Create two separate databases with the same information that I would need to synchronize regularly between JAVA and CordovaJS in the two ways? Synchronization can possibly lead to the same problem of dual access ...
Create two bases, and communicate via flat files containing JSON data ...
Not to use databases and move only by flat files in JSON?
Any other ideas?
I'd rather largely retain only one database ...
Thank you in advance for review
PS: Sorry for my English, I'm French :(
EDIT:
Here is one of the errors occurs: W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '+data+data+com_app+databases+db.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
An other error seems like android.database.sqlite.SQLiteException: error code 5: database is locked

Categories

Resources