Share Intent from IntentService in Android

Nitya Raut
Updated on 30-Jul-2019 22:30:25

415 Views

Before getting into example, we should know what Intent service is in android. Intent Service is going to do back ground operation asynchronously. When user call startService() from activity , it doesn’t create instance for each request. It going to stop service after done some action in service class or else we need to stop service using stopSelf().This example demonstrate about How to share intent from intentservice.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. ... Read More

Set a Pair Value in Java Tuple

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

The setAtX() method is used to set the Pair value in JavaTuples and a copy with a new value at the specified index i.e. index x.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Pair Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Pair; public ... Read More

Where MySQL Database Gets Saved When Created

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

478 Views

If you want the database location i.e. where it is created in MySQL, you can use system variable @@datadir.The syntax is as followsSELECT @@datadir;The following is the querymysql> select @@datadir;Here is the output. The above query returns the location+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Now reach the above directory in your system. The screenshot of the ... Read More

Upload a File Using JSP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

539 Views

A JSP can be used with an HTML form tag to allow users to upload files to the server. An uploaded file can be a text file or a binary or an image file or just any document.Creating a File Upload FormLet us now understand how to create a file upload form. The following HTML code creates an uploader form. Following are the important points to be noted down −The form method attribute should be set to the POST method and the GET method cannot be used.The form enctype attribute should be set to multipart/form-data.The form action attribute should be ... Read More

Use Trim in Android TextView

Smita Kapse
Updated on 30-Jul-2019 22:30:25

3K+ Views

This example demonstrate about How to use trim () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken name as Edit text, when user click on button it will take data and trim the data without spaces.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import ... Read More

lastIndexOf Method of AbstractList Class in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

103 Views

The lastIndexOf() method of the AbstractList return the index of the last occurrence of an element in the list. If the element does not exist in the list, then -1 is returned.The syntax is as followspublic int lastIndexOf(Object ob)Here, the parameter ob is the element to be searched. To work with the AbstractList class, import the following packageimport java.util.AbstractList;The following is an example to implement lastIndexOf() method of the AbstractlList class in JavaExample Live Demoimport java.util.ArrayList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = new ArrayList();       myList.add(75); ... Read More

Find MongoDB Records Where Array Field is Not Empty

Smita Kapse
Updated on 30-Jul-2019 22:30:25

3K+ Views

You can use $ne(Not Equal) operator for this. To understand the concept, let us create a collection with document. The query to create a collection with document is as follows −> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Larry", "StudentTechnicalSubject":["Java", "C"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76fe2f1e9c5dd6f1f78291") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Mike", "StudentTechnicalSubject":[]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76fe3b1e9c5dd6f1f78292") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Sam", "StudentTechnicalSubject":["MongoDB"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76fe491e9c5dd6f1f78293") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Carol", "StudentTechnicalSubject":[]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76fe521e9c5dd6f1f78294") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"David", "StudentTechnicalSubject":["MySQL", "SQL Server"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76fe661e9c5dd6f1f78295") }Display all documents ... Read More

Delete All Records of a Collection in MongoDB Shell

Smita Kapse
Updated on 30-Jul-2019 22:30:25

702 Views

To delete all records of a collection in MongoDB shell, use the remove() method. The syntax is as follows −db.yourCollectionName.remove({});To understand the syntax, let us create a collection with document. The query to create a collection with document is as follows −> db.deleteAllRecordsDemo.insertOne({"StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f6ca32f684a30fbdfd596") } > db.deleteAllRecordsDemo.insertOne({"StudentName":"Carol", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f6cb22f684a30fbdfd597") } > db.deleteAllRecordsDemo.insertOne({"StudentName":"Mike", "StudentAge":23, "Hobby":["Learning", "Photography"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f6cde2f684a30fbdfd598") }Display all documents from a collection with the help of find() method. The query is as follows −> db.deleteAllRecordsDemo.find().pretty();The following ... Read More

Add New Column to Existing Table Using JDBC API

Nitya Raut
Updated on 30-Jul-2019 22:30:25

3K+ Views

You can add a new column to a table using the ALTER TABLE command.SyntaxALTER TABLE table_name ADD column_name datatype;Assume we have a table named Sales in the database with 5 columns namely ProductName, CustomerName, DispatchDate, DeliveryTime, Price and, Location as shown below:+-------------+--------------+--------------+--------------+-------+----------------+ | ProductName | CustomerName | DispatchDate | DeliveryTime | Price | Location       | +-------------+--------------+--------------+--------------+-------+----------------+ | Key-Board   | Raja         | 2019-09-01   | 08:51:36     | 7000  | Hyderabad      | | Earphones   | Roja         | 2019-05-01   | 05:54:28     | 2000 ... Read More

What is Rowset and How to Retrieve Table Contents Using Rowset

Samual Sam
Updated on 30-Jul-2019 22:30:25

1K+ Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet a RowSet follows JavaBeans component model. This can be used as a JavaBeans component in a visual Bean development environment, i.e. in environments like IDE’s you can visually manipulate these properties.Connecting RowSet with databaseThe RowSet interface provides methods to set Java bean properties to connect it to the required database −void setURL(String url):void setUserName(String user_name):void setPassword(String password):PropertiesA RowSet object contains properties and each property have Setter and getter methods. Using these you can set and get values from a command ... Read More

Advertisements