Use Shared Preferences in Android Between Activities

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

292 Views

This example demonstrate about How to use shared preference in Android between activities.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.         Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     ... Read More

Flush Output Stream After Writing Bytes

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

513 Views

Let us first crate OutputStream with file input.txt −FileOutputStream fileStream = new FileOutputStream("E:/input.txt"); DataOutputStream dataStream = new DataOutputStream(fileStream);Now, the writeBytes() method writes out the string to the underlying output stream as a sequence of bytes.dataStream.writeBytes("Demo text!");Flush the output stream −dataStream.flush();The following is an example. Here, our file is “E:/input.txt” and at the end we are flushing the output stream −Exampleimport java.io.DataOutputStream; import java.io.FileOutputStream; public class Demo {    public static void main(String[] args) throws Exception {       FileOutputStream fileStream = new FileOutputStream("E:/input.txt");       DataOutputStream dataStream = new DataOutputStream(fileStream);       dataStream.writeBytes("Demo text!");       ... Read More

Check If Data Is Null in MySQL

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

429 Views

You can use IF() to check if data is NULL.  Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(200),    Age int ); Query OK, 0 rows affected (0.44 sec)Insert records in the table using insert command −mysql> insert into DemoTable(Name, Age) values('John', 23); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name, Age) values('Sam', null); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name, Age) values('Mike', 23); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Name, Age) values('David', 21); Query OK, ... Read More

Data File Mode in 8085 Microprocessor

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

491 Views

DATA FILE MODE in8085 MicroprocessorWe can refer to ‘X8085 cross-assembler’ manual for details.The format of Intel Hex: We have shown the MULT.HEX file to give a brief description at a glance.:01 C100 00 04 3A:01 C200 00 05 38:02 C300 00 00 00 3B:10 C000 00 21 00 C1 5E 16 00 21 00 C2 7E 21 00 00FE 00 CA 90:10 C010 00 17 C0 19 3D C2 12 C0 22 F7 FF 22 00C3 CD BC 06 D3:01 C020 00 76 A9:00 0000 01 FFThere are several lines which the file consists of which are termed as records. ... Read More

Reset In and Reset Out Pins in 8085

George John
Updated on 30-Jul-2019 22:30:25

2K+ Views

Intel 8085 consists of a RESET_IN* pin which is an active low input pin. We RESET 8085 by placing a logic 0 on this pin at least for 0.5μs, after that the power is supplied to Vcc pin of 8085. Moreover, in practice we place the RESET_IN* in logic 0 state for a few milliseconds. A typical reset circuit which we use in ALS 8085 kit, is shown in the following Fig.The moment when the power supply is switched on, the Vcc pin gets +5V power here the RESET_IN* pin stays in logic 0 state for a time dependency on the ... Read More

Check If Cursor ArrayList Is Empty in Android SQLite

Anvi Jain
Updated on 30-Jul-2019 22:30:25

695 Views

Before getting into example, we should know what sqlite data base 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 demonstrate about How to check cursor array list is empty or not in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and ... Read More

Use Rotate for ListView in Android

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

270 Views

This example demonstrate about How to use rotate() for Listview 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 name and record number as Edit text, when user click on save button it will store the data into arraylist. Click on refresh button to ... Read More

Call Functions Using Callable Statements in JDBC

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

2K+ Views

Like procedures, you can also create function in a database and store them.SyntaxFollowing is the syntax of creating a function in a(MySQL) database:CREATE FUNCTION Function_Name(input_arguments) RETURNS output_parameter BEGIN    declare variables;    statements . . . . . . . . . .    return data_type;    ENDExampleSuppose we have a table named Emp in the database with the following content:+--------+------------+----------------+ | Name   | DOB        | Location      | +--------+------------+----------------+ | Amit   | 1970-01-08 | Hyderabad      | | Sumith | 1970-01-08 | Vishakhapatnam | | Sudha  | 1970-01-05 | Vijayawada     ... Read More

Use SUM in Android SQLite

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

874 Views

Before getting into example, we should know what sqlite data base 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 demonstrate about How to use SUM () in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

IndexOf Method of AbstractSequentialList in Java

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

124 Views

The indexOf() method is inherited from the AbstractList class. It is used to return the index of the first occurrence of the specified element in this list. If the list is empty, it returns -1.The syntax is as follows −public int indexOf(Object ele)Here, ele is the element for which you want the index.To work with the AbstractSequentialList class in Java, you need to import the following package −import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList indexOf() method in Java −Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       ... Read More

Advertisements