i'm trying to do mail program. i've done this using jsonArray, Http protocals and some other functions. But, now i want to implement the program likely unread mails and starred mails. If i'm pressing anyof new mail it'll assign likely 1 to database. Otherwise, keep it 0. And, also if i want to set any mails in important (starred) this will keep 1 to database. Otherwise, keep 0. Now, i want to create a database related to these concepts? Anyone know about this concept Please help me to do this? Thanks in advance.
Use SQLite,
Below tutorial will help you to get started,
http://developer.android.com/guide/topics/data/data-storage.html#db
http://www.vogella.de/articles/AndroidSQLite/article.html#overview_sqlite
Good luck!
Edited :
Create a database with a table "Whatever name"
Than have content such as
|SeqNo|MailFrom|MailTo|Subject|Body|Starred|etc...|
Example
|1|blah#clah.com|blahblah#blah.com|Hi|Hello|0|etc...|
|2|bla1#clah.com|blahbfgv#blah.com|Hi|Hello|1|etc...|
Hope you can match example with given table format, It's like a simple SQL database where you can query while loading inbox and check whether user has selected a mail and starred it! However you can create those star button which will change state of that table's column while being click.
Related
I'm going to build an app. Until now everything runs very well. Now I have a problem. The app gets its content from a mysql database.A column is called item.I have a ratingbar. The user can rate the item there.Every time the user evaluates an item the value is stored on the database in the respective item line.The values are then added. In other words, when a user evaluates 20 times with 5 stars, the value adds up to 100 and so on.
I want to limit this. I will that the user can evaluate each day only once an item. I will it without a registration mask for the user. How can I solve this problem?
I know that i can identifier the WIFI MAC Adreess and other Unique Identifiers, but how can i solve this with them?
I can not use sqlite database, because the items should update with the time from the mysql database.
A registration mask should not be excluded. If this process is quite possible with them, then I supplement it with it.
I am looking forward to every comment
every computer has a machine ID, you will hash that and encrypt that to use as your identifier..most telecomms do not like using MAc addresses as IDs
One option would be to create UUID during every installation and sending this UUID to your server along with every request. In server, you can control very well if user can provide feedback once a day or others based on your requirement. Pls refer this link on how to create UUID.
https://developer.android.com/reference/java/util/UUID.html
I need to get the only data which is updated, I am getting complete data which is affecting the performance. So whenever a client hit the API I want to send the only changes (updated data) from DB which is related to client.
There is a scenario just like facebook. If user goes offline at 12 o'clock for 1 hour i.e he will be get online at 1 o'clock. Now I need to send the notifications to him that which activities are done within offline time period.
I am using timestamp right now but Is their any other better option ?
I don't want to use timestamp or flag for last session ending time.
Thanks in advance
Try to use Versioning concept there u can get latest record .. or try to get latest record from database of that client.
There must be a column which might be an identification for updates, like last_modified_date or something. Apply the same in where clause and execute the query.
I am not sure but i know in mongo db oplog can be use to monitored changes in database , i guess like that mysql log can be use to do such monitoring if you can access it with your code. may be i am still not sure you can give it a try
I'm currently developing an application in Java that connects to a MySQL database using JDBC, and displays records in jTable. The application is going to be run by more than one user at a time and I'm trying to implement a way to see if the table has been modified. EG if user one modifies a column such as stock level, and then user two tries to access the same record tries to change it based on level before user one interacts.
At the moment I'm storing the checksum of the table that's being displayed as a variable and when a user tries to modify a record it will do a check whether the stored checksum is the same as the one generated before the edit.
As I'm new to this I'm not sure if this a correct way to do it or not; as I have no experience in this matter.
Calculating the checksum of an entire table seems like a very heavy-handed solution and definitely something that wouldn't scale in the long term. There are multiple ways of handling this but the core theme is to do as little work as possible to ensure that you can scale as the number of users increase. Imagine implementing the checksum based solution on table with million rows continuously updated by hundreds of users!
One of the solutions (which requires minimal re-work) would be to "check" the stock name against which the value is updated. In the background, you'll fire across a query to the table to see if the data for "that particular stock" has been updated after the table was populated. If yes, you can warn the user or mark the updated cell as dirty to indicate that that value has changed. The problem here is that the query won't be fired off till the user tries to save the updated value. Or you could poll the database to avoid that but again hardly an efficient solution.
As a more robust solution, I would recommend using a database which implements native "push notifications" to all the connected clients. Redis is a NoSQL database which comes to mind for this.
Another tried and tested technique would be to forgo direct database connection and use a middleware layer like a messaging queue (e.g. RabbitMQ). Message queues enable design of systems which communicate using message. So for e.g. every update the stock value in the JTable would be sent across as a message to an "update database queue". Once the update is done, a message would be sent across to a "update notification queue" to which all clients would be connected. This will enable all of them to know that the value of a given stock has been updated and act accordingly. The advantage to this solution is that you get to keep your existing stack (Java, MySQL) and can implement notifications without polling the DB and killing it.
Checksum is a way to see if data has changed.
Anyway I would suggest you store a column "last_update_date", this column is supposed to be always updated at every update of the record.
So you juste have to store this date (precision date time) and do the check with that.
You can also add a column version number : a simple counter incremented by 1 at each update.
Note:
You can add a trigger on update for updating last_update_date, it should be 100% reliable, maybe you don't need a trigger if you control all updates.
When using in network communication:
A checksum is a count of the number of bits in a transmission unit
that is included with the unit so that the receiver can check to see
whether the same number of bits arrived. If the counts match, it's
assumed that the complete transmission was received.
So it can be translated to check 2 objects are different, your approach is correct.
I have some problem like this.
I am accessing a database which is currently having over 100,000 data in new entry table.
Now I want to write a listener, means if any new record insert to table from somewhere else I have to get a notification.
My question is: What is best and fastest way to do this? because for a day there should have around 500 new data in the new entry table. Is is suitable to check the database every time using a thread?
Im using Java to do this with MySQL.
Please advice me.
I am not sure whether there is any listener that exists for Mysql changes. So it wouldn't be straight forward to get these details.
But there is something called 'The Binary Log' in mysql, which contains “events” that describe database changes such as table creation operations or changes to table data.
So one way to track the changes can be polling these logs. The challenge is that these logs are written in binary format. Mysql provides a utility called mysqlbinlog to process these logs in text format.
Here is one java parser for your rescue, which can read the mysql binary logs:
https://github.com/tangfl/jbinlog
Integrating all this bits and pieces , you may be able to get what you need.
try out this...
numero = stmt.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
Take a look at the documentation for the JDBC Statement interface.
I used java timer class for as an alternative to this solution. Now it works fine. It checks the database in every 10 seconds and if the condition true, it will execute what I want.
I have to develop a application with the following scenario:
1--User create a profil (name,lastname,address....)
2--The information are inserted in the database
3--The administrator should receive an e-mail to be notified by the new profil ,if the administrator dont
approve the profil he will delete it.
Is there a way to send automatically an e-mail when a row is inserted in the database?
I'm using java.
If you are doing this through a common interface, then I'd suggest putting a seperate call next to the insert routine (between Java and database).
I heard you can do a whole lot of things with triggers in MS SQL, but I was told to keep my hands away from triggers. Made by the devil to make a day turn bad. People that has succesfully mastered triggers will tell you otherwise.