This example demonstrate about How to get programmatically android Radio version information.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required detailsto 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 radio version number.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.app.ProgressDialog; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.provider.Settings; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.webkit.CookieManager; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; ... Read More
Before getting into an example, we should know what SQLite database in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built-in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrates How to use MIN () in Android SQLite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a ... Read More
An immutable copy of a LocalTime with the minutes altered as required is done using the method withMinute() in the LocalTime class in Java. This method requires a single parameter i.e. the minute that is to be set in the LocalTime and it returns the LocalTime with the minute altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalTime lt1 = LocalTime.parse("23:15:30"); System.out.println("The LocalTime is: " + lt1); LocalTime lt2 = lt1.withMinute(45); ... Read More
This type of error occurs when number of columns does not match whenever you are inserting records in the destination table. For a demo example, let us create a tablemysql> create table errorDemo -> ( -> User_Id int NOT NULL AUTO_INCREMENT, -> User_Name varchar(20), -> PRIMARY KEY(User_Id) -> ); Query OK, 0 rows affected (0.47 sec)The error is as followsmysql> insert into errorDemo values('John'); ERROR 1136 (21S01): Column count doesn't match value count at row 1To avoid this type of error, you need to use the following syntaxinsert into yourTableName(yourColumnName1, yourColumnName2, ...N)values(yourValue1, yourValue2, ....N);Insert some ... Read More
To understand the query on list field, and/or, you can create a collection with documents.The query to create a collection with a document is as follows −> db.andOrDemo.insertOne({"StudentName":"Larry", "StudentScore":[33, 40, 50, 60, 70]}); { "acknowledged" : true, "insertedId" : ObjectId("5c9522d316f542d757e2b444") } > db.andOrDemo.insertOne({"StudentName":"Larry", "StudentScore":[87, 67, 79, 98, 90]}); { "acknowledged" : true, "insertedId" : ObjectId("5c95230916f542d757e2b445") }Display all documents from a collection with the help of find() method. The query is as follows −> db.andOrDemo.find().pretty();The following is the output −{ "_id" : ObjectId("5c9522d316f542d757e2b444"), "StudentName" : "Larry", "StudentScore" : [ 33, ... Read More
This example demonstrate about How to get available wifi networks and display them in a list in 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/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.content.Context; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.net.wifi.WifiManager; import android.os.Build; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; public class ... Read More
With this, get the milliseconds in days, hours and minutes. At first, set the Duration −Duration d1 = Duration.ofDays(20); Duration d2 = Duration.ofHours(100); Duration d3 = Duration.ofMinutes(150);Convert the above Duration to nanoseconds −System.out.println("Milliseconds in 20 days = "+d1.toMillis()); System.out.println("Milliseconds in 100 hours = "+d2.toMillis()); System.out.println("Milliseconds in 150 minutes = "+d3.toMillis());Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d1 = Duration.ofDays(20); Duration d2 = Duration.ofHours(100); Duration d3 = Duration.ofMinutes(150); System.out.println("Milliseconds in 20 days = "+d1.toMillis()); System.out.println("Milliseconds in 100 hours ... Read More
This is a type of comment. The /* is the beginning of a comment and */ is the end of comment.Let us implement and display how to create a commentmysql> /* This is the first MySQL Program */MySQL will ignore the above comment.Let us see an example. Here, we have written a comment with /* and */mysql> /*This table has information about person */ mysql> create table DemoTable ( PersonId int NOT NULL AUTO_INCREMENT PRIMARY KEY, PersonName varchar(20), PersonAge int ); Query OK, 0 rows affected (0.58 sec)
An easily readable description of the provider and its services can be obtained using the method getInfo() in the class java.security.Provider. This method requires no parameters and it returns a provider and services description.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo { public static void main(String[] argv) throws Exception { try { SecureRandom sRandom = SecureRandom.getInstance("SHA1PRNG"); Provider p = sRandom.getProvider(); System.out.println("The information is as follows:"); System.out.println(p.getInfo()); } catch ... Read More
This example demonstrates How to list files from SD card with runtime permission 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 list view and button. When user click on button, it will take data from external storage and append the data to list view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.pm.PackageManager; import ... Read More