Posts

Update data in SQLite

Image
"Update data in SQLite"      In previous blog we have studied about CREATE,INSERT,SELECT,DELETE operation on SQLite. We missed up about UPDATE operation. Today we are going to learn how to update data in SQLite table.   If you understand how to insert data in SQLite, then it is very easy to learn UPDATE. Lets see following code snippet, here i have created two methods one for update mobile number and one for update email. The update() method is used for performing update operation. It contains Table name, content values and where clause. Just copy and paste this method in previous project's SQLiteHelper.java file.    //update number public long updateMobileData(String number) { SQLiteDatabase sqLiteDatabase = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put(COL2, number); long result = sqLiteDatabase.update(TableName, contentValues, COL2 + "=?...

SQLite with RecyclerView

Image
"SQLite with RecyclerView"      I hope you enjoying with android coding. Today we are going to study about how to perform CRUD operation with SQLite using RecyclerView.    SQLite is a opensource database to store text data in a device. The SQLite comes with built in database implementation in android. There is no need to established any kind of connections like JDBC etc. You can implement ist by extending SQLiteOpenHelper class.   Ok, let's start with CREATE table , INSERT data and SELECT data operation.    In previous blog we have study about RecyclerView implementation. So, here i'am going to post only about SQLite database.    Let's start with creating table, First you need to create one class and extend with SQLiteOpenHelper as shown in below code snippet. There are two methods are override by extendning SQLiteOpenHelper class, namely onCreate and onUpgrade method.    In onCreate method we have to c...

Swipe to delete RecyclerView Item

Image
"Swipe To Delete RecyclerView"    In previous blog we have studied how to implement RecyclerView in android. Now we are going to studying about touch events in RecyclerView. In this blog I'm going to write about how to delete row from RecyclerView by swipe from left to right or vice versa. For implementing touch event in RecyclerView we need to attach ItemTouchHelper. See the following code snippet. First create removeItem() method as shown in following code and paste it in "RecyclerAdapter.java" class, created in previous example. public void removeItem(int position){ listItems.remove(position); imageArray.remove(position); notifyItemRemoved(position); notifyDataSetChanged(); } Now copy and paste the code after setting adapter to recyclerview as shown in previous demo of RecyclerView. //TODO : Create and set adapter to RecyclerView final RecyclerAdapter recyclerAdapter = new Re...

RecyclerView Android

Image
"RecyclerView"      In previous two blogs we have studied about how to create ListView with array adapter and Custom Adapter using BaseAdapter class. In this blog we are going to study about what is RecyclerView and how to implement it in android. Before studying about it lets understand what is main difference between ListView and RecyclerView. RecyclerView is flexible version of ListView , If you want to show large data set in list or data that frequently change you should use RecyclerView. The views in RecyclerView are represented by View Holder objects. Each view holder represents a single view. RecyclerView creates view holder as are needed to display the on screen portion of the dynamic content.  In RecyclerView the creating view and binding values with UI components are separating in thwo methods called : onCreateViewholder() and onBindViewHolder(). In other hand the ListView does not separating it, rather it create view and bind values ...

CustomListView

      "Custom ListView"          Hello friends, In previous blog we are studied about ListView with ArrayAdapter. Now in this block weare going to study about custom ListView using BaseAdapter.      In previous blog we have created one Simple ListView that contains only text. The custom ListView means creating custom layout of list items. In this tutorial we are going to adding image, text and button in one list row.      Before implementing custom ListView lets know about BaseAdapter. In Android, an Adapter is a bridhe between UI component and data source (Like, ArrayList, Array etc) that help us to fill data in UI components.     To customize ListView we can create own Adapter class with own layout file by extending BaseAdapter class. BaseAdapter can be used for implementing custom ListView, GridView , Spinner etc.     The following code snippet shows the overrid methods of Bas...

ListView In Android

"ListView" Hi friends, Today we are going to learn what is listView and how to implement in android? ListView is group of items and all items are display in vertical scrollable view. The list items are inserted in listview by using adapter. Here using ArrayAdapter and We will learn Base adapter in next tutorial. Lets start to implement listview with array adapter in android. Create one layout file that contains following code. Here the name of file is "activity_main.xml" In above file we have added ListView and set an id "list_demo". Now create one java file and paste the following code. Here the name of file is "MainActivity.java" package com.beauty.listviewdemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { //Create ListView...