I have created a chat app using firebase, I want to store the chat data in the user device and show to the user if the internet is not available.
I am torn between how to implement it I wanted to use realm but it increases app size almost by 6mb(my app size is 4mb), so I switched back to SQLite.
Now I want to know what would be the best practice to do so
I have implemented few processes still unclear how to do.
I have created a master_chat table in which I have message_id, to ,from and thread_id and secondary chat_data table where I used message_id as a reference to master_chat table and inserted messageBody, toEmail, fromEmail, time, messageType,fileSize ,downloadLink
now the question is should I follow this method so that everytime user enter the message it will be added to chat_data or directly store the arrayList and update it every time a message is sent or received.
any guidance will be great!
Related
I'm designing a fitness app where a trainer would upload workouts to a database and a client could access those workouts via an app. This is easy enough to setup, however, I'm struggling to find a good way to upload workouts to a database in a way that someone who is non technical could easily do. I've been primarily playing around with FirebaseDB, but I'm open to suggestions. I'm trying to avoid having to create my own app for the trainer to input data and upload to the database as it will take extra time. Is this the best approach?
If you are thinking to expand your app in near future i suggest you to avoid FirebaseDB. Go with MS-SQL. Create User Table and add a Field may be called as 'Member_Types' (Admin|User). If the logged in user is Admin then Show him Different Page from where He can Upload Data by just inserting in Textboxes/Dropdowns/etc,etc and Clicking One Button Click. Whereas if the user logged in as a USER type show him the page which shows the data uploaded by Admin.
Using FirebaseDB is OK but If you want to deal with really complex data which this app can (In case to want to expand this app and want to add more and more features). I even Suggest if u are going with MS-SQL , Create your Own WebAPI to handle the requests.
All the Very Best for your App.
I'm developing an Android application , i have to develop an activity that contains a simple communications board .
The information that i want show are contained in a database , When the user started the activity the informations are downloaded , parsed and Showed to users.
Now i would implement a function That notify to the user When a new information is inserted in the db.
Now what that i don't understand is:
I need to implement a service that runs in background and polls the database and notify to the user when a information is inserted or can i use only the GMC (now FCM) ?
If i don't want use GCM there are another solution to do this ?
I have read some thread in stack overflow and there are different solution but i don't understand what is the best solution for my problem.
Speaking at a high-level, here's what I would do.
If I didn't want to use GCM then I would write my own service to make an http request to my backend web server to check if any new information is available. If any new info is received save it to my local Android database and refresh the app. I'd use Android's AlarmManager to start this service every so often (hourly, daily, whatever frequency I want).
I am developing a app and want to see offline data if Internet is not available . And this app can use multiple user like as after logout one user then another user can login and can see own data So how we can make database to accessible for among user
Use a discrimator column in your database table design to mark owner ship of every record.
Then you can impl. your data access methods so that they only query records for active user.
It's a design issue not a developing problem ;)
In my app, each user has a table of records says:
id, friend_name, message
My goal is to store this data in Android phone, so that each time a user log in, he/she can populate this list quickly. At server side, I already had a record of friend relationship...etc. Now I just want to keep a small database in Android side for each user because loading from the server takes times, plus I realize that these data are distinct among users. Let's says:
- User A has messages: a, b, c
- User B has messages: d, e, f
...
I read about SharePreference, but I guess it's inappropriate here since SP is only good for key/pair values. Then I look over sqllite database, it's straightforward. But what I don't understand is how can we make sure that each time a new user log in, he/she will have his/her own database but not others? I can keep a key/pair value flag for each user in SharedPreference to check if the database already existed, but then where do I store these databases? For n users, I would have to store n databases, that sounds impractical.
So what's the best way to store my data in this case?
You wouldn't create a new database for each user. What you need to focus on is good database design. In this particular case you would create a table for messages, a table for users and a table that holds links between users and messages using their ids. When a user logs into your app, you would find the messages that are linked to this user. A good database design also makes sure there is no redundant data (=duplicate data, for instance storing the same message twice). Look into database normalization if you want to learn more about that.
You can use UUID.getRandomUUID() behaviour. I have seen this at GOOGLE I/O Protips movie.
http://www.youtube.com/watch?feature=player_embedded&v=twmuBbC_oB8
I am working on a contacts backup and sync.
The target is to send all details of all contacts to a server (custom protocol defined) as a backup.
During initial launch of application, all the contacts will be queued and sent to the server.
And after that, a background service will be running all time which will listen to new contact addition/ contact update, and this new/updated contact will be sent to server by the background service.
I am using RawContactsEntity for fetching the records.
I tried using ContentObserver on RawContacts/Data tables to get notification of contact addition or contact-change. But, AFAIK, the ContentObserver gives notification (onChange()) of changed data in table as a whole and not ID of individual record.
Now my problem is, how to get the exact id's of changed/new records?
I thought of creating a backup-table to compare with native contacts table and get the changed records. But as the number of contacts increase, the performance will decease drastically and this will hamper the battery life too.
Can you suggest me, The best way for achieving this contacts backup operation from performance and memory usage point of view?
Is there any other way for contacts sync operation?
It would be very helpful if anyone can share examples which can help me in this.
If the contacts are stored within your account(AccountManger), Android will mark the dirty flag in raw contacts. If it is not your account then you can not trust the dirty flag as the accounts sync adapter might have updated the contact to the server and reset the dirty flag. Your only option is to either re-upload the full contacts(simple and easy to code) or keep track of the version column in RawContacts and check which one has changed. It is actually not recommended to copy and upload contacts from other accounts as the corresponding sync adapter will anyways maintain a backup of those. Like Google will have a copy of Google contacts on their server.