├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ └── add.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── add.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── add.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── add.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── menu
│ │ │ │ └── add.xml
│ │ │ ├── xml
│ │ │ │ ├── button.xml
│ │ │ │ └── input.xml
│ │ │ └── layout
│ │ │ │ ├── activity_list.xml
│ │ │ │ ├── list_item.xml
│ │ │ │ ├── activity_detail_data.xml
│ │ │ │ ├── activity_edit.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── shashank
│ │ │ │ └── crud
│ │ │ │ ├── Constants.java
│ │ │ │ ├── Model.java
│ │ │ │ ├── DetailData.java
│ │ │ │ ├── RequestHandler.java
│ │ │ │ ├── ListActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── EditActivity.java
│ │ │ │ └── MyAdapter.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── shashank
│ │ │ └── crud
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── shashank
│ │ └── crud
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── android_API
├── crud_api
│ ├── index.php
│ ├── connection.php
│ ├── delete.php
│ ├── add.php
│ ├── update.php
│ ├── select.php
│ └── select_id.php
└── crud_android.sql
├── ScreenShots
├── 1.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
└── 6.png
├── .idea
├── caches
│ ├── gradle_models.ser
│ └── build_file_checksums.ser
├── modules.xml
├── misc.xml
├── runConfigurations.xml
├── gradle.xml
└── codeStyles
│ └── Project.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── ReadMe Run Project.txt
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/android_API/crud_api/index.php:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/ScreenShots/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/ScreenShots/1.png
--------------------------------------------------------------------------------
/ScreenShots/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/ScreenShots/2.png
--------------------------------------------------------------------------------
/ScreenShots/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/ScreenShots/3.png
--------------------------------------------------------------------------------
/ScreenShots/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/ScreenShots/4.png
--------------------------------------------------------------------------------
/ScreenShots/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/ScreenShots/5.png
--------------------------------------------------------------------------------
/ScreenShots/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/ScreenShots/6.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CRUD
3 |
4 |
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/drawable-hdpi/add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/drawable-mdpi/add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/drawable-xhdpi/add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/drawable-xxhdpi/add.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shashank-p/CRUD-Android-App/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Feb 27 23:38:34 IST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/android_API/crud_api/connection.php:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ReadMe Run Project.txt:
--------------------------------------------------------------------------------
1 | * Paste the android_API folder to WWW or htdocs in server
2 | * Rename only android_API folder to android OR change the name of the file in Constant.jav file in Android (path to API)
3 | * Change the Connection file with your DB and Table details
4 | * Within android_API -> you'll find sql file (import in your Database after creating DB -> crud_android table anme -> data)
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/add.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/android_API/crud_api/delete.php:
--------------------------------------------------------------------------------
1 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/button.xml:
--------------------------------------------------------------------------------
1 |
3 | -
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/input.xml:
--------------------------------------------------------------------------------
1 |
3 | -
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/test/java/com/shashank/crud/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/android_API/crud_api/add.php:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/android_API/crud_api/update.php:
--------------------------------------------------------------------------------
1 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/Constants.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | /**
4 | * Created by Asus on 07/02/2018.
5 | */
6 |
7 | public class Constants {
8 | public static final String URL= "http://192.168.43.68/";
9 | public static final String ROOT_URL = URL+"android/crud_api/";
10 | public static final String URL_ADD = ROOT_URL+"add.php";
11 | public static final String URL_DELETE = ROOT_URL+"delete.php";
12 | public static final String URL_UPDATE = ROOT_URL+"update.php";
13 | public static final String URL_SELECT = ROOT_URL+"select.php";
14 | public static final String URL_SELECT_ID = ROOT_URL+"select_id.php";
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/Model.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | public class Model {
4 | String id,uid,name,phone,address;
5 |
6 | public Model(String id ,String uid, String name, String phone, String address ) {
7 | this.id = id;
8 | this.uid = uid;
9 | this.name = name;
10 | this.phone = phone;
11 | this.address = address;
12 | }
13 |
14 | public String getId(){
15 | return id;
16 | }
17 | public String getUId(){
18 | return uid;
19 | }
20 | public String getName(){
21 | return name;
22 | }
23 |
24 | public String getPhone(){
25 | return phone;
26 | }
27 |
28 | public String getAddress(){
29 | return address;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/android_API/crud_api/select.php:
--------------------------------------------------------------------------------
1 |
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CRUD-Android-App
2 | CRUD Android App using Volley, JSON, Php API and MySql Database
3 |
4 | It is Simple Create, Read, Update and Delete function capable Android App, It uses Java based Native Code with PHP API and MySql Databse for CRUD operations.
5 |
6 | It uses Volley Library for CRUD Operations over Android App Network. In this we also used JSON for data transfer.
7 |
8 | Do read the Read Me file in Project to Run Project (Just Simple Guide to begin with)
9 |
10 |
11 | It is built to work on Android 5.1 & above
12 |
13 | Technologies used: Android, Java, XML, PHP, MySQL
14 |
15 | IDE: Android Studio 3.3.1
16 |
17 | 
18 | 
19 | 
20 | 
21 | 
22 | 
23 |
--------------------------------------------------------------------------------
/android_API/crud_api/select_id.php:
--------------------------------------------------------------------------------
1 |
32 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/shashank/crud/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.code_revolution.siswa", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/DetailData.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.widget.TextView;
6 |
7 | public class DetailData extends AppCompatActivity {
8 | TextView uid, name, address, phone;
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_detail_data);
13 |
14 | uid = (TextView) findViewById(R.id.uid);
15 | name = (TextView) findViewById(R.id.name);
16 | address = (TextView) findViewById(R.id.address);
17 | phone = (TextView) findViewById(R.id.phone);
18 |
19 | uid.setText(getIntent().getStringExtra("uid"));
20 | name.setText(getIntent().getStringExtra("name"));
21 | address.setText(getIntent().getStringExtra("address"));
22 | phone.setText(getIntent().getStringExtra("phone"));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.code_revolution.siswa"
7 | minSdkVersion 19
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
24 | exclude group: 'com.android.support', module: 'support-annotations'
25 | })
26 | implementation 'com.android.support:appcompat-v7:28.0.0'
27 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
28 | implementation 'com.android.volley:volley:1.1.1'
29 | implementation 'com.android.support:cardview-v7:28.0.0'
30 | implementation 'com.android.support:recyclerview-v7:28.0.0'
31 | testImplementation 'junit:junit:4.12'
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/RequestHandler.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.content.Context;
4 |
5 | import com.android.volley.Request;
6 | import com.android.volley.RequestQueue;
7 | import com.android.volley.toolbox.Volley;
8 |
9 |
10 | public class RequestHandler {
11 | private static RequestHandler mInstance;
12 | private RequestQueue mRequestQueue;
13 | private static Context mCtx;
14 |
15 | private RequestHandler(Context context) {
16 | mCtx = context;
17 | mRequestQueue = getRequestQueue();
18 | }
19 |
20 | public static synchronized RequestHandler getInstance(Context context) {
21 | if (mInstance == null) {
22 | mInstance = new RequestHandler(context);
23 | }
24 | return mInstance;
25 | }
26 |
27 | public RequestQueue getRequestQueue() {
28 | if (mRequestQueue == null) {
29 | // getApplicationContext() is key, it keeps you from leaking the
30 | // Activity or BroadcastReceiver if someone passes one in.
31 | mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
32 | }
33 | return mRequestQueue;
34 | }
35 |
36 | public void addToRequestQueue(Request req) {
37 | getRequestQueue().add(req);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/android_API/crud_android.sql:
--------------------------------------------------------------------------------
1 | -- phpMyAdmin SQL Dump
2 | -- version 4.7.4
3 | -- https://www.phpmyadmin.net/
4 | --
5 | -- Host: 127.0.0.1:3306
6 | -- Generation Time: Feb 27, 2019 at 06:45 PM
7 | -- Server version: 5.7.19
8 | -- PHP Version: 5.6.31
9 |
10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11 | SET AUTOCOMMIT = 0;
12 | START TRANSACTION;
13 | SET time_zone = "+00:00";
14 |
15 |
16 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19 | /*!40101 SET NAMES utf8mb4 */;
20 |
21 | --
22 | -- Database: `crud_android`
23 | --
24 |
25 | -- --------------------------------------------------------
26 |
27 | --
28 | -- Table structure for table `data`
29 | --
30 |
31 | DROP TABLE IF EXISTS `data`;
32 | CREATE TABLE IF NOT EXISTS `data` (
33 | `id` int(11) NOT NULL AUTO_INCREMENT,
34 | `uid` varchar(20) NOT NULL,
35 | `name` varchar(100) NOT NULL,
36 | `phone` varchar(30) NOT NULL,
37 | `address` varchar(150) NOT NULL,
38 | PRIMARY KEY (`id`)
39 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
40 |
41 | --
42 | -- Dumping data for table `data`
43 | --
44 |
45 | INSERT INTO `data` (`id`, `uid`, `name`, `phone`, `address`) VALUES
46 | (1, '978545698869', 'Shashank P', '8987589538', 'Belagavi'),
47 | (2, '123445677890', 'Test Matt', '8545253698', 'NY, USA');
48 | COMMIT;
49 |
50 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
51 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
52 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
53 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
25 |
26 |
34 |
35 |
42 |
43 |
47 |
48 |
51 |
52 |
58 |
59 |
65 |
66 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_detail_data.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
19 |
20 |
28 |
29 |
36 |
37 |
43 |
44 |
51 |
52 |
58 |
59 |
66 |
67 |
73 |
74 |
81 |
82 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
17 |
25 |
26 |
32 |
33 |
42 |
43 |
49 |
50 |
59 |
60 |
66 |
67 |
76 |
77 |
83 |
84 |
93 |
94 |
95 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
18 |
26 |
27 |
33 |
34 |
43 |
44 |
50 |
51 |
60 |
61 |
67 |
68 |
77 |
78 |
84 |
85 |
94 |
95 |
96 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/ListActivity.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Intent;
5 | import android.database.Cursor;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.support.v7.widget.DefaultItemAnimator;
9 | import android.support.v7.widget.LinearLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.widget.ListView;
14 | import android.widget.Toast;
15 |
16 | import com.android.volley.AuthFailureError;
17 | import com.android.volley.Request;
18 | import com.android.volley.Response;
19 | import com.android.volley.VolleyError;
20 | import com.android.volley.toolbox.StringRequest;
21 |
22 | import org.json.JSONArray;
23 | import org.json.JSONException;
24 | import org.json.JSONObject;
25 |
26 | import java.util.ArrayList;
27 | import java.util.HashMap;
28 | import java.util.List;
29 | import java.util.Map;
30 |
31 | public class ListActivity extends AppCompatActivity {
32 |
33 | public static ListActivity ma;
34 | protected Cursor cursor;
35 | ArrayList thelist;
36 | ListView listview;
37 | List listItems;
38 | private RecyclerView recyclerView;
39 | private RecyclerView.Adapter adapter;
40 | ProgressDialog progressDialog;
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_list);
45 | getSupportActionBar().setTitle("Data");
46 | recyclerView = (RecyclerView) findViewById(R.id.list);
47 | recyclerView.setLayoutManager(new LinearLayoutManager(ListActivity.this));
48 | progressDialog = new ProgressDialog(this);
49 | listItems = new ArrayList<>();
50 | ma = this;
51 | refresh_list();
52 | }
53 |
54 | public boolean onCreateOptionsMenu(Menu menu) {
55 | getMenuInflater().inflate(R.menu.add, menu);
56 | return true;
57 | }
58 |
59 | public boolean onOptionsItemSelected(MenuItem item) {
60 | int id = item.getItemId();
61 | if (id == R.id.add) {
62 |
63 | Intent tes = new Intent(ListActivity.this, MainActivity.class);
64 | startActivity(tes);
65 | }
66 | return super.onOptionsItemSelected(item);
67 | }
68 |
69 |
70 | public void refresh_list(){
71 | listItems.clear();
72 | adapter = new MyAdapter(listItems,getApplicationContext());
73 | recyclerView.setAdapter(adapter);
74 |
75 | recyclerView.setItemAnimator(new DefaultItemAnimator());
76 | progressDialog.setMessage("Loading");
77 | progressDialog.show();
78 |
79 | StringRequest stringRequest = new StringRequest(Request.Method.POST, Constants.URL_SELECT, new Response.Listener() {
80 | @Override
81 | public void onResponse(String response) {
82 | progressDialog.dismiss();
83 | try{
84 |
85 | progressDialog.hide();
86 | JSONObject jsonObject = new JSONObject(response);
87 | JSONArray jsonArray = jsonObject.getJSONArray("data");
88 |
89 | Toast.makeText(ListActivity.this,jsonObject.getString("message"),Toast.LENGTH_SHORT).show();
90 | for (int i = 0; i getParams() throws AuthFailureError {
118 | Map params = new HashMap<>();
119 | params.put("name", "kl");
120 | return params;
121 | }
122 | };
123 | RequestHandler.getInstance(ListActivity.this).addToRequestQueue(stringRequest);
124 | }
125 |
126 |
127 |
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.app.ProgressDialog;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.text.TextUtils;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.android.volley.AuthFailureError;
13 | import com.android.volley.Request;
14 | import com.android.volley.Response;
15 | import com.android.volley.VolleyError;
16 | import com.android.volley.toolbox.StringRequest;
17 |
18 | import org.json.JSONException;
19 | import org.json.JSONObject;
20 |
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | public class MainActivity extends AppCompatActivity {
25 |
26 | EditText uid, name, address, phone;
27 | String Uid, Name, Address, Phone;
28 | Button button;
29 | Boolean valid = true;
30 | ProgressDialog progressDialog;
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_main);
35 |
36 | uid = (EditText) findViewById(R.id.uid);
37 | name = (EditText) findViewById(R.id.name);
38 | address = (EditText) findViewById(R.id.address);
39 | phone = (EditText) findViewById(R.id.phone);
40 | progressDialog = new ProgressDialog(this);
41 | button = (Button) findViewById(R.id.button);
42 |
43 | button.setOnClickListener(new View.OnClickListener() {
44 | @Override
45 | public void onClick(View view) {
46 | Uid = uid.getText().toString();
47 | Name = name.getText().toString();
48 | Address = address.getText().toString();
49 | Phone = phone.getText().toString();
50 |
51 | if(TextUtils.isEmpty(Uid)){
52 | uid.setError("UID Cannot be Empty");
53 | valid = false;
54 | }else {
55 | valid = true;
56 |
57 | if(TextUtils.isEmpty(Name)){
58 | name.setError("Name Cannot be Empty");
59 | valid = false;
60 | }else {
61 | valid = true;
62 |
63 | if(TextUtils.isEmpty(Address)){
64 | address.setError("Address Cannot be Empty");
65 | valid = false;
66 | }else {
67 | valid = true;
68 |
69 | if(TextUtils.isEmpty(Phone)){
70 | phone.setError("Contact Number Cannot be Empty");
71 | valid = false;
72 | }else {
73 | valid = true;
74 | }
75 | }
76 |
77 | }
78 | }
79 |
80 | if(valid){
81 | progressDialog.setMessage("Loading");
82 | progressDialog.show();
83 |
84 | StringRequest stringRequest = new StringRequest(Request.Method.POST, Constants.URL_ADD, new Response.Listener() {
85 | @Override
86 | public void onResponse(String response) {
87 | progressDialog.dismiss();
88 | try{
89 | JSONObject jsonObject = new JSONObject(response);
90 | Toast.makeText(MainActivity.this, jsonObject.getString("message"), Toast.LENGTH_SHORT).show();
91 | if(jsonObject.getString("message").equals("Data Added Successfully")){
92 | ListActivity.ma.refresh_list();
93 | finish();
94 | }
95 | }catch (JSONException e) {
96 | e.printStackTrace();
97 | }
98 | }
99 | }, new Response.ErrorListener() {
100 | @Override
101 | public void onErrorResponse(VolleyError error) {
102 | progressDialog.hide();
103 | Toast.makeText(MainActivity.this, "Failed to Data",Toast.LENGTH_SHORT).show();
104 | }
105 | }){
106 | protected Map getParams() throws AuthFailureError {
107 | Map params = new HashMap<>();
108 | params.put("name", Name);
109 | params.put("uid", Uid);
110 | params.put("phone", Phone);
111 | params.put("address",Address);
112 | return params;
113 | }
114 | };
115 | RequestHandler.getInstance(MainActivity.this).addToRequestQueue(stringRequest);
116 |
117 | }
118 | }
119 | });
120 |
121 |
122 |
123 | }
124 |
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/EditActivity.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.app.ProgressDialog;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.text.TextUtils;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.android.volley.AuthFailureError;
13 | import com.android.volley.Request;
14 | import com.android.volley.Response;
15 | import com.android.volley.VolleyError;
16 | import com.android.volley.toolbox.StringRequest;
17 |
18 | import org.json.JSONException;
19 | import org.json.JSONObject;
20 |
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | public class EditActivity extends AppCompatActivity {
25 | EditText uid, name, address, phone;
26 | String Uid, Name, Address, Phone, Id;
27 | Button button;
28 | Boolean valid = true;
29 | ProgressDialog progressDialog;
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_edit);
34 |
35 | uid = (EditText) findViewById(R.id.uid);
36 | name = (EditText) findViewById(R.id.name);
37 | address = (EditText) findViewById(R.id.address);
38 | phone = (EditText) findViewById(R.id.phone);
39 | progressDialog = new ProgressDialog(this);
40 | button = (Button) findViewById(R.id.button);
41 |
42 | Id = getIntent().getStringExtra("id");
43 | uid.setText(getIntent().getStringExtra("uid"));
44 | name.setText(getIntent().getStringExtra("name"));
45 | address.setText(getIntent().getStringExtra("address"));
46 | phone.setText(getIntent().getStringExtra("phone"));
47 |
48 | button.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View view) {
51 | Uid = uid.getText().toString();
52 | Name = name.getText().toString();
53 | Address = address.getText().toString();
54 | Phone = phone.getText().toString();
55 |
56 | if(TextUtils.isEmpty(Uid)){
57 | uid.setError("UID Cannot be Empty");
58 | valid = false;
59 | }else {
60 | valid = true;
61 |
62 | if(TextUtils.isEmpty(Name)){
63 | name.setError("Name Cannot be Empty");
64 | valid = false;
65 | }else {
66 | valid = true;
67 |
68 | if(TextUtils.isEmpty(Address)){
69 | address.setError("Address Cannot be Empty");
70 | valid = false;
71 | }else {
72 | valid = true;
73 |
74 | if(TextUtils.isEmpty(Phone)){
75 | phone.setError("Contact Number Cannot be Empty");
76 | valid = false;
77 | }else {
78 | valid = true;
79 | }
80 | }
81 |
82 | }
83 | }
84 |
85 | if(valid){
86 | progressDialog.setMessage("Loading");
87 | progressDialog.show();
88 |
89 | StringRequest stringRequest = new StringRequest(Request.Method.POST, Constants.URL_UPDATE, new Response.Listener() {
90 | @Override
91 | public void onResponse(String response) {
92 | progressDialog.dismiss();
93 | try{
94 | JSONObject jsonObject = new JSONObject(response);
95 | Toast.makeText(EditActivity.this, jsonObject.getString("message"), Toast.LENGTH_SHORT).show();
96 | if(jsonObject.getString("message").equals("Edit Data Successful")){
97 | ListActivity.ma.refresh_list();
98 | finish();
99 | }
100 | }catch (JSONException e) {
101 | e.printStackTrace();
102 | }
103 | }
104 | }, new Response.ErrorListener() {
105 | @Override
106 | public void onErrorResponse(VolleyError error) {
107 | progressDialog.hide();
108 | Toast.makeText(EditActivity.this, "Failed",Toast.LENGTH_SHORT).show();
109 | }
110 | }){
111 | protected Map getParams() throws AuthFailureError {
112 | Map params = new HashMap<>();
113 | params.put("id", Id);
114 | params.put("name", Name);
115 | params.put("uid", Uid);
116 | params.put("phone", Phone);
117 | params.put("address",Address);
118 | return params;
119 | }
120 | };
121 | RequestHandler.getInstance(EditActivity.this).addToRequestQueue(stringRequest);
122 |
123 | }
124 | }
125 | });
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/crud/MyAdapter.java:
--------------------------------------------------------------------------------
1 | package com.shashank.crud;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.support.v7.app.AlertDialog;
8 | import android.support.v7.widget.CardView;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import com.android.volley.AuthFailureError;
17 | import com.android.volley.Request;
18 | import com.android.volley.Response;
19 | import com.android.volley.VolleyError;
20 | import com.android.volley.toolbox.StringRequest;
21 |
22 | import java.util.HashMap;
23 | import java.util.List;
24 | import java.util.Map;
25 |
26 | public class MyAdapter extends RecyclerView.Adapter{
27 |
28 | private List listItems;
29 | private Context context;
30 | private ProgressDialog dialog;
31 |
32 |
33 | public MyAdapter(List listItems, Context context) {
34 | this.listItems = listItems;
35 | this.context = context;
36 | }
37 |
38 | public class ViewHolder extends RecyclerView.ViewHolder {
39 |
40 | public TextView id;
41 | public TextView uid;
42 | public TextView name;
43 | public TextView address;
44 | public TextView phone;
45 | public CardView card_view;
46 | public ViewHolder(View itemView ) {
47 | super(itemView);
48 | id = (TextView) itemView.findViewById(R.id.id);
49 | uid = (TextView) itemView.findViewById(R.id.uid);
50 | name = (TextView) itemView.findViewById(R.id.name);
51 | address = (TextView) itemView.findViewById(R.id.address);
52 | phone = (TextView) itemView.findViewById(R.id.phone);
53 | card_view = (CardView) itemView.findViewById(R.id.card_view);
54 | }
55 |
56 |
57 | }
58 |
59 |
60 | @Override
61 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
62 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
63 | return new ViewHolder(v);
64 | }
65 |
66 | @Override
67 | public void onBindViewHolder(ViewHolder holder, final int position) {
68 | final Model listItem = listItems.get(position);
69 | holder.id.setText(listItem.getId());
70 | holder.uid.setText(listItem.getUId());
71 | holder.name.setText(listItem.getName());
72 | holder.address.setText(listItem.getAddress());
73 | holder.phone.setText(listItem.getPhone());
74 |
75 | holder.card_view.setOnClickListener(new View.OnClickListener() {
76 | @Override
77 | public void onClick(final View view) {
78 | Intent intent;
79 | AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
80 | final ProgressDialog dialog = new ProgressDialog(view.getContext());
81 | dialog.setMessage("Loading Delete Data");
82 | final CharSequence[] dialogitem = {"View Data","Edit Data","Delete Data"};
83 | builder.setTitle(listItem.getName());
84 | builder.setItems(dialogitem, new DialogInterface.OnClickListener() {
85 | @Override
86 | public void onClick(DialogInterface dialogInterface, int i) {
87 | switch (i){
88 | case 0 :
89 | Intent intent = new Intent(view.getContext(), DetailData.class);
90 | intent.putExtra("id", listItem.getId());
91 | intent.putExtra("uid",listItem.getUId());
92 | intent.putExtra("name",listItem.getName());
93 | intent.putExtra("address",listItem.getAddress());
94 | intent.putExtra("phone", listItem.getPhone());
95 | view.getContext().startActivity(intent);
96 | break;
97 | case 1 :
98 |
99 | Intent intent2 = new Intent(view.getContext(), EditActivity.class);
100 | intent2.putExtra("id", listItem.getId());
101 | intent2.putExtra("uid",listItem.getUId());
102 | intent2.putExtra("name",listItem.getName());
103 | intent2.putExtra("address",listItem.getAddress());
104 | intent2.putExtra("phone", listItem.getPhone());
105 | view.getContext().startActivity(intent2);
106 | break;
107 | case 2 :
108 |
109 | AlertDialog.Builder builderDel = new AlertDialog.Builder(view.getContext());
110 | builderDel.setTitle(listItem.getName());
111 | builderDel.setMessage("Are You Sure, You Want to Delete Data?");
112 | builderDel.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
113 |
114 | @Override
115 | public void onClick(DialogInterface dialogInterface, int i) {
116 | dialog.show();
117 |
118 | StringRequest stringRequest = new StringRequest(Request.Method.POST, Constants.URL_DELETE, new Response.Listener() {
119 | @Override
120 | public void onResponse(String response) {
121 | dialog.hide();
122 | dialog.dismiss();
123 | Toast.makeText(view.getContext(),"Successfully Deleted Data "+ listItem.getName(),Toast.LENGTH_LONG).show();
124 | ListActivity.ma.refresh_list();
125 |
126 | }
127 | }, new Response.ErrorListener() {
128 | @Override
129 | public void onErrorResponse(VolleyError error) {
130 | dialog.hide();
131 | dialog.dismiss();
132 | }
133 | }){
134 | protected HashMap getParams() throws AuthFailureError {
135 | Map params= new HashMap<>();
136 | params.put("id",listItem.getId());
137 | return (HashMap) params;
138 |
139 | }
140 | };
141 | RequestHandler.getInstance(view.getContext()).addToRequestQueue(stringRequest);
142 | dialogInterface.dismiss();
143 | }
144 | });
145 |
146 | builderDel.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
147 | @Override
148 |
149 | public void onClick(DialogInterface dialogInterface, int i) {
150 | dialogInterface.dismiss();
151 | }
152 | });
153 |
154 |
155 | builderDel.create().show();
156 | break;
157 | }
158 | }
159 | });
160 |
161 | builder.create().show();
162 | }
163 | });
164 | }
165 |
166 | @Override
167 | public int getItemCount() {
168 | return listItems.size();
169 | }
170 | }
--------------------------------------------------------------------------------