How should I implement friend's data loading? - java

I'm writing an Android app using the phone number as the ID. I am getting all the contacts from the client's phone. I want to display to the user all of his contacts whom installed the app (just like whatsapp).
I was thinking about sending to the server all of the contacts and execute a search for each one of them to check if they exist in the db, and send back all the registered players. I am afraid this implementation will slow my app since I have to load all of his friends on every loading page (in case of new contacts that installed the app, or deleted and so on)
What are your thoughts about it?

Use a contacts cache and invalidate/recreate it whenever the contacts DB change, use code such as how to listen for changes in Contact Database. That should make your suggested approach fast enough.
Cheers.

Related

How do i make 2 people access the same db (android app dev)?

i'm making an android app where 2 people ,with different account, can access the same database and read some data (the data is all text). Now i'm asking how can i do that. Is it better if i make a remote db and than make the devices access to the database, and if so how can i do that whitout killing my server? Or there is any other way to do this? Ty
You can try to combine SQLite with Firebase. Check this post for a reference.

Pass Data from android in home to android in office via online

I have a problem, I build an application for android that can open a single led with the use of bluetooth module and it succesfully works, now my problem is what if I want to open my led in my home while im at my office. What will I do is I will left another android that can open the led in my office and I will make another android application that will pass a data in my database and that data will retrieve by my android in my office and will trigger to open the LED.. I need tips on how I will gonna do that.. thanks
What you can do is have a realtime database like Firebase Realtime Database to store your data you need to communicate. So when a data is changed or updated your Phones will have the fresh data in sync. and then you can trigger changes accordingly
For eg, if the device in your office, clicks (Turn On LED), it will update the Firebase database with a value like (true), on the other side the device at your home would read the value, and check if the value is (true), then run the code to turn on the LED

Update Android App Database

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.

sync data to server android

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

Registration in app right way

I am want to do registration in my app. So i have made all requests to my web service.
I now when user is registered.
Now i need to save somewhere that he is registered that don't give him registration form again.
How to do this ?
Do i need to save somewhere in my sqlite database and every time when app lunches check if he is registered user. Or maybe in app settings i could save this information.
I am new to developing android app and i am searching for the right way.
Thanks all for help.
You could save that with SharedPreferences. Check the link for sample code.
http://developer.android.com/guide/topics/data/data-storage.html#pref.
This data will be removed if the users uninstalls the app or clears all data from system menu.
Edit: If you really want to remember preferences across installs you should try Backup API. http://developer.android.com/guide/topics/data/backup.html
The best solution is to use Android's Account Manager to handle user account. This aproach is the most secure (credentials are not exposed), however it has two drawbacks:
It's a little bit complocated to set up
It requires at least API version 5
Once the user registered you can save in your sqlite database and you have to check for each time when your application launches. But if the user uninstalled the application and tried to reinstall it ll ask for registration again.. In order to avoid this you have to store the information like the device id and the registered details in some servers and also in sqlite database and have to check when the application launches...

Categories