Image compression using java

There are no specific API is available for compressing the images.

Supported format files are JPG (Joint Photography Experts Group) and PNG (Portable Network Graphics)
  • Download Jar (Java Archive) which is developed by Java Query API
  • Create a instance using ImageResize Class and using that object call the method compressImage
Sample

ImageResize ir = new ImageResize();
 ir.compressImage("Source Location", "Destination ", width, height);

String Parameter: Source Location and Destination
Integer Parameter: width and height

Parameters Description:

·         1st Parameter : Source Location , Example c:\\demo\\image.jpg
·         2nd Parameter : if you mention “default” then it will compress the original image and if you mention the destination location then it will create a new compressed image
·         3rd Parameter  & 4th Parameter : if you enter 0 for both then image resolution will not change but if you mention some value greater than 0 then image resolution will be changed.

That’s it.  Thanks to the Java Query API for implementing this API.

Remove The Word From Android Keyboard Suggestion

When you type something on android keyboard then android system automatically saved the entered text word for suggesting these words next time when you just begin with few character.


You can do with setting to enable or disable auto saving feature but how you will delete a particular word?

Here is the image of suggesting the words when i start typing the “an” keyword


I need to delete the “anwered” from the suggestion


So hold your finger on “anwered” from some seconds automatically a popup will appear with Remove confirmation and you click the ok button to remove the keyword from already saved words that you entered.

Google Web Toolkit Local Storage

Learn how you can implement the local storage using Google web tool kit.


Local storage helps you to keep the data on client machine or end user machine but never use an important data on local storage because local storage is not a secure storage.

Creating an instance using Storage class and also checking whether the browser supports local storage or not using getLocalStorageIfSupported() method.

Storage stockStore = Storage.getLocalStorageIfSupported();

Insert the data using setItem() method , fetch data using getItem() method and clear the local storage data using clear() method.

stockStore.setItem(String key, String data);
stockStore.getItem(String key);
stockStore.clear();}

Set Item has two parameters, one is key and another one is data. Key is used to maintain the index and data is the parameter where we can save the string which is needed in other place.

Example :-
stockStore.setItem(“userName”,”demo”);
stockStore.setItem(“companyName”, “company”);


Get Item has only one parameter i.e., key , so enter the key to get a particular value.

Example:-
stockStore.getItem(“userName”); // retrieve demo
stockStore.getItem(“companyName”); // retrieve company

Solution : Cannot delete or update a parent row: a foreign key constraint fails

Whenever you want to delete a particular row from a parent table, usually a database engine checks whether this parent data primary key value refers to any child table data.

For Example,

Table: user

id
login_Id
user_Name
1
demo001
Note
2
demo002
Book

Table: userAddress

id
user_id
Country
State
1
1
India
Himachal Pradesh
2
2
India
Tamil Nadu

Primary Key
Foreign Key

Table UserAddress has “user_id” is a foreign key reference from Table User.

So User Table is Parent Table and UserAddress Table is Child Table

If you are try to delete any data in child table then you might be not facing an error but if you try to delete any data in parent table then you will face problem “Cannot delete or update a parent row: a foreign key constraint fails” because parent table data is referencing to child table.

Execute this Query

SET FOREIGN_KEY_CHECKS = 0;

After executing the above query

Now try to delete the parent table data which is referencing to child table data then database engine won’t be checking and it will delete without any problem.

To Do the Reset

SET FOREIGN_KEY_CHECKS = 1;