- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
This example demonstrate about How to get android application first installation date.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 text view to show first installation date.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.telephony.TelephonyManager; import android.view.WindowManager; import android.widget.TextView; import java.text.DateFormat; import java.text.SimpleDateFormat; import ... Read More
The ResultSetMetaData provides information about the obtained ResultSet object like, the number of columns, names of the columns, datatypes of the columns, name of the table etc…Following are some methods of ResultSetMetaData class.MethodDescriptiongetColumnCount()Retrieves the number of columns in the current ResultSet object.getColumnLabel()Retrieves the suggested name of the column for use.getColumnName()Retrieves the name of the column.getTableName()Retrieves the name of the table.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; public class ResultSetMetadataExample { public static void main(String args[]) throws Exception { //Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Getting the connection ... Read More
This example demonstrate about How use action move event in android.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 a text view to perform an action move event.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.view.MotionEventCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.TextView; import android.widget.Toast; public class ... Read More
To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then the graph is not connected.For the undirected graph, we will select one node and traverse from it.In this case the traversal algorithm is recursive DFS traversal.Input − Adjacency matrix of a graph0110010110110110110100110Output − The Graph is connected.Algorithmtraverse(u, visited)Input − The start node u and the visited node to mark which node is visited.Output: Traverse all connected vertices.Begin mark u as visited for all ... Read More
To set all values in a single column MySQL query, you can use UPDATE command.The syntax is as follows.update yourTableName set yourColumnName =yourValue;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table setAllValuesDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Amount int -> ); Query OK, 0 rows affected (0.64 sec)Now you can insert some records in the table using insert command.The query is as follows.mysql> insert into setAllValuesDemo(Name, Amount) values('John', 2345); Query OK, 1 row affected ... Read More
To get the geographic coordinates of the place that is longitude and latitude of the place we can use google maps geocoding api.RequirementTo get the coordinates of a place, we required geocoding api & you can get it from below link:https://developers.google.com/maps/documentation/geocoding/get-api-keyApart from api_key, we are going to use pythonRequest module (fetch the coordinates)Json module (for conversion).Below is the program to achieve the same:# Import required library import requests import json #Enter the place name place = input("Please enter place name: ") #Place your google map API_KEY to a variable apiKey = 'YOUR_API_KEY' #Store google geocoding api url in a variable ... Read More
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.Linear probing is a collision resolving technique in Open Addressed Hash tables. In this method, each cell of a hash table stores a single key–value pair. If a collision is occurred by mapping a new key to a cell of the hash table that is already occupied by another key. This method searches the table for the following closest free location and inserts the ... Read More
Before getting into an example, we should know what ConcurrentLinkedDeque is, it is unbounded deque based on linked nodes. Multiple threads can access deque elements with safety.This example demonstrates about How to use pollLast() in android ConcurrentLinkedDequeStep 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 a text view to show ConcurrentLinkedDeque elements.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; ... Read More
This example demonstrate about How to Use WiFi Direct on AndroidStep 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. Step 3 − Add the following code to src/WifiDirectBroadcastReceiverpackage com.example.myapplication; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.wifi.p2p.WifiP2pManager; import android.widget.Toast; public class WifiDirectBroadcastReceiver extends BroadcastReceiver { WifiP2pManager wifiP2pManager; WifiP2pManager.Channel channel; MainActivity activity; public WifiDirectBroadcastReceiver(WifiP2pManager wifiP2pManager, WifiP2pManager.Channel channel, MainActivity activity) { this.wifiP2pManager = wifiP2pManager; ... Read More
To get Sub Map from TreeMap, let us first create a TreeMap and set key-value pair −TreeMaptMap = new TreeMap(); tMap.put("1", "A"); tMap.put("2", "B"); tMap.put("3", "C"); tMap.put("4", "D"); tMap.put("5", "E"); tMap.put("6", "F"); tMap.put("7", "G");Now, let’s say you need to get submap from 3 to 7. For that, use the method submap() as −=SortedMapmap = tMap.subMap("3", "7");Example Live Demoimport java.util.SortedMap; import java.util.TreeMap; public class Demo { public static void main(String[] args) { TreeMaptMap = new TreeMap(); tMap.put("1", "A"); tMap.put("2", "B"); tMap.put("3", "C"); tMap.put("4", "D"); ... Read More