androidd 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. androidd/__init__.py +1 -0
  2. androidd/cie1/activityCycle/MainActivity.kt +44 -0
  3. androidd/cie1/activityCycle/activity_main.xml +15 -0
  4. androidd/cie1/alert/MainActivity.kt +28 -0
  5. androidd/cie1/alert/activity_main.xml +14 -0
  6. androidd/cie1/autoCompleteText/MainActivity.kt +19 -0
  7. androidd/cie1/autoCompleteText/activity_main.xml +14 -0
  8. androidd/cie1/checkbox/MainActivity.kt +28 -0
  9. androidd/cie1/checkbox/activity_main.xml +32 -0
  10. androidd/cie1/customCheckbox/MainActivity.kt +20 -0
  11. androidd/cie1/customCheckbox/activity_main.xml +22 -0
  12. androidd/cie1/customCheckbox/custom_checkbox.xml +9 -0
  13. androidd/cie1/customRadio/MainActivity.kt +22 -0
  14. androidd/cie1/customRadio/activity_main.xml +28 -0
  15. androidd/cie1/customRadio/custom_checkbox.xml +9 -0
  16. androidd/cie1/customToast/MainActivity.kt +35 -0
  17. androidd/cie1/customToast/activity_main.xml +14 -0
  18. androidd/cie1/customToast/custom_toast.xml +23 -0
  19. androidd/cie1/datepicker/MainActivity.kt +31 -0
  20. androidd/cie1/datepicker/activity_main.xml +20 -0
  21. androidd/cie1/progressbar/MainActivity.kt +26 -0
  22. androidd/cie1/progressbar/activity_main.xml +21 -0
  23. androidd/cie1/radiobutton/MainActivity.kt +25 -0
  24. androidd/cie1/radiobutton/activity_main.xml +38 -0
  25. androidd/cie1/timePicker/MainActivity.kt +30 -0
  26. androidd/cie1/timePicker/activity_main.xml +20 -0
  27. androidd/cie1/toast/MainActivity.kt +18 -0
  28. androidd/cie1/toast/activity_main.xml +14 -0
  29. androidd/cie1/toggle/MainActivity.kt +20 -0
  30. androidd/cie1/toggle/activity_main.xml +23 -0
  31. androidd/madbmsj/IMPLICIT and EXPLICIT/Main Activity.kt +31 -0
  32. androidd/madbmsj/IMPLICIT and EXPLICIT/activity_main.xml +33 -0
  33. androidd/madbmsj/IMPLICIT and EXPLICIT/second.xml +16 -0
  34. androidd/madbmsj/IMPLICIT and EXPLICIT/secondactivity.kt +15 -0
  35. androidd/madbmsj/animation/MainActivity.kt +60 -0
  36. androidd/madbmsj/animation/activity_main.xml +122 -0
  37. androidd/madbmsj/animation/bounce.xml +17 -0
  38. androidd/madbmsj/animation/fad_in.xml +7 -0
  39. androidd/madbmsj/animation/fade_out.xml +8 -0
  40. androidd/madbmsj/animation/info.txt +2 -0
  41. androidd/madbmsj/animation/slide_down.xml +7 -0
  42. androidd/madbmsj/animation/slide_up.xml +7 -0
  43. androidd/madbmsj/animation/zoom_in.xml +11 -0
  44. androidd/madbmsj/animation/zoom_out.xml +11 -0
  45. androidd/madbmsj/canvas/MainActivity.kt +51 -0
  46. androidd/madbmsj/canvas/activity_main.xml +18 -0
  47. androidd/madbmsj/cie1/code.txt +719 -0
  48. androidd/madbmsj/cie1/sampleQuestion.txt +280 -0
  49. androidd/madbmsj/cie2/code.txt +1255 -0
  50. androidd/madbmsj/cie2/ques1/AndroidManifest.xml +2 -0
  51. androidd/madbmsj/cie2/ques1/MainActivity.kt +45 -0
  52. androidd/madbmsj/cie2/ques1/SecondActivity.kt +21 -0
  53. androidd/madbmsj/cie2/ques1/activity_main.xml +19 -0
  54. androidd/madbmsj/cie2/ques1/activity_second.xml +15 -0
  55. androidd/madbmsj/cie2/ques1/department_menu.xml +11 -0
  56. androidd/madbmsj/contextMenu/MainActivity.kt +37 -0
  57. androidd/madbmsj/contextMenu/activity_main.xml +19 -0
  58. androidd/madbmsj/contextMenu/info.txt +1 -0
  59. androidd/madbmsj/contextMenu/menu_main.xml +16 -0
  60. androidd/madbmsj/database/DatabaseHelper.kt +108 -0
  61. androidd/madbmsj/database/MainActivity.kt +151 -0
  62. androidd/madbmsj/database/activity_main.xml +55 -0
  63. androidd/madbmsj/database/dialog_update_student.xml +22 -0
  64. androidd/madbmsj/database/info.txt +4 -0
  65. androidd/madbmsj/datePicker/MainActivity.kt +23 -0
  66. androidd/madbmsj/datePicker/activity_main.xml +20 -0
  67. androidd/madbmsj/explicit/activity_main.xml +39 -0
  68. androidd/madbmsj/explicit/activity_second.xml +15 -0
  69. androidd/madbmsj/explicit/info.txt +6 -0
  70. androidd/madbmsj/explicit/mainactivity.kt +32 -0
  71. androidd/madbmsj/explicit/secondactivity.kt +27 -0
  72. androidd/madbmsj/fragment/MainActivity.kt +35 -0
  73. androidd/madbmsj/fragment/activity_main.xml +41 -0
  74. androidd/madbmsj/fragment/fragment_1.kt +24 -0
  75. androidd/madbmsj/fragment/fragment_1.xml +16 -0
  76. androidd/madbmsj/fragment/fragment_2.kt +17 -0
  77. androidd/madbmsj/fragment/fragnent_2.xml +16 -0
  78. androidd/madbmsj/fragment/info.txt +1 -0
  79. androidd/madbmsj/optionsMenu/MainActivity.kt +26 -0
  80. androidd/madbmsj/optionsMenu/activity_main.xml +18 -0
  81. androidd/madbmsj/optionsMenu/info.txt +1 -0
  82. androidd/madbmsj/optionsMenu/menu_main.xml +27 -0
  83. androidd/madbmsj/package.json +13 -0
  84. androidd/madbmsj/popMenu/MainActivity.kt +49 -0
  85. androidd/madbmsj/popMenu/activity_main.xml +19 -0
  86. androidd/madbmsj/popMenu/info.txt +1 -0
  87. androidd/madbmsj/popMenu/menu_main.xml +16 -0
  88. androidd/madbmsj/sharedpref/shared1/activity_main.xml +64 -0
  89. androidd/madbmsj/sharedpref/shared1/mainactivity.kt +47 -0
  90. androidd/madbmsj/sharedpref/shared2/activity_main.xml +44 -0
  91. androidd/madbmsj/sharedpref/shared2/mainactivity.kt +57 -0
  92. {androidd-0.0.1.dist-info → androidd-0.0.2.dist-info}/METADATA +1 -1
  93. androidd-0.0.2.dist-info/RECORD +95 -0
  94. androidd-0.0.2.dist-info/top_level.txt +1 -0
  95. androidd-0.0.1.dist-info/RECORD +0 -4
  96. androidd-0.0.1.dist-info/top_level.txt +0 -1
  97. {androidd-0.0.1.dist-info → androidd-0.0.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,32 @@
1
+
2
+ package com.example.myapplication
3
+
4
+ import android.content.Intent
5
+ import android.support.v7.app.AppCompatActivity
6
+ import android.os.Bundle
7
+ import android.widget.Button
8
+ import android.widget.EditText
9
+
10
+ class MainActivity : AppCompatActivity() {
11
+ override fun onCreate(savedInstanceState: Bundle?) {
12
+ super.onCreate(savedInstanceState)
13
+ setContentView(R.layout.activity_main)
14
+
15
+ val nameEt = findViewById<EditText>(R.id.nameEt)
16
+ val emailEt = findViewById<EditText>(R.id.emailEt)
17
+ val phoneEt = findViewById<EditText>(R.id.phoneEt)
18
+ val saveBtn = findViewById<Button>(R.id.saveBtn)
19
+
20
+ saveBtn.setOnClickListener {
21
+ val name = nameEt.text.toString()
22
+ val email = emailEt.text.toString()
23
+ val phone = phoneEt.text.toString()
24
+
25
+ val intent = Intent(this, SecondActivity::class.java)
26
+ intent.putExtra("Name", name)
27
+ intent.putExtra("Email", email)
28
+ intent.putExtra("Phone", phone)
29
+ startActivity(intent)
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,27 @@
1
+ package com.example.myapplication
2
+
3
+ import android.content.Intent
4
+ import android.os.Bundle
5
+ import android.support.v7.app.AppCompatActivity
6
+ import android.widget.Button
7
+ import android.widget.TextView
8
+
9
+ class SecondActivity : AppCompatActivity() {
10
+ override fun onCreate(savedInstanceState: Bundle?) {
11
+ super.onCreate(savedInstanceState)
12
+ setContentView(R.layout.activity_second)
13
+ //get data from intent
14
+ val intent = intent
15
+ val name = intent.getStringExtra("Name")
16
+ val email = intent.getStringExtra("Email")
17
+ val phone = intent.getStringExtra("Phone")
18
+ //textview
19
+ val resultTv = findViewById<TextView>(R.id.resultTv)
20
+ //setText
21
+ resultTv.text = "Name: "+name+"\nEmail: "+email+"\nPhone: "+phone
22
+ }
23
+ }
24
+
25
+ add this in manifest before closing of application
26
+
27
+ <activity android:name=".SecondActivity" />
@@ -0,0 +1,35 @@
1
+ package com.example.fragments
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.support.v4.app.Fragment
6
+ import android.support.v4.app.FragmentManager
7
+ import android.widget.Button
8
+
9
+ @Suppress("DEPRECATION")
10
+ class MainActivity : AppCompatActivity() {
11
+ override fun onCreate(savedInstanceState: Bundle?) {
12
+ super.onCreate(savedInstanceState)
13
+ setContentView(R.layout.activity_main)
14
+ // lateinit var fragmentManager: FragmentManager
15
+ var blueButton = findViewById<Button>(R.id.blueButton);
16
+ var yellowButton = findViewById<Button>(R.id.yellowButton);
17
+ // fragmentManager = getSupportFragmentManager();
18
+
19
+ blueButton.setOnClickListener {
20
+ loadFragment(fragment_1())
21
+ }
22
+
23
+ yellowButton.setOnClickListener {
24
+ loadFragment(fragment_2())
25
+ }
26
+ }
27
+
28
+ private fun loadFragment(fragment: Fragment) {
29
+ // Use supportFragmentManager directly
30
+ supportFragmentManager.beginTransaction()
31
+ .replace(R.id.fragmentContainer, fragment)
32
+ .addToBackStack(null)
33
+ .commit()
34
+ }
35
+ }
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context=".MainActivity">
8
+
9
+ <FrameLayout
10
+ android:id="@+id/fragmentContainer"
11
+ android:layout_width="410dp"
12
+ android:layout_height="399dp"
13
+ app:layout_constraintStart_toStartOf="parent"
14
+ app:layout_constraintTop_toTopOf="parent">
15
+
16
+ </FrameLayout>
17
+
18
+ <Button
19
+ android:id="@+id/blueButton"
20
+ android:layout_width="0dp"
21
+ android:layout_height="wrap_content"
22
+ android:layout_marginTop="56dp"
23
+ android:layout_weight="1"
24
+ android:text="Fragment 1"
25
+ android:backgroundTint="#2196F3"
26
+ app:layout_constraintStart_toStartOf="parent"
27
+ app:layout_constraintTop_toBottomOf="@+id/fragmentContainer"
28
+ tools:ignore="ExtraText" />
29
+
30
+ <Button
31
+ android:id="@+id/yellowButton"
32
+ android:layout_width="0dp"
33
+ android:layout_height="wrap_content"
34
+ android:layout_marginTop="56dp"
35
+ android:layout_weight="1"
36
+ android:text="Fragment 2"
37
+ android:backgroundTint="#FFEB3B"
38
+ app:layout_constraintEnd_toEndOf="parent"
39
+ app:layout_constraintTop_toBottomOf="@+id/fragmentContainer" />
40
+
41
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1,24 @@
1
+
2
+ package com.example.fragments
3
+
4
+ import android.os.Bundle
5
+ import android.support.v4.app.Fragment
6
+ import android.view.LayoutInflater
7
+ import android.view.View
8
+ import android.view.ViewGroup
9
+
10
+ // TODO: Rename parameter arguments, choose names that match
11
+ // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
12
+ private const val ARG_PARAM1 = "param1"
13
+ private const val ARG_PARAM2 = "param2"
14
+
15
+ /**
16
+ * A simple [Fragment] subclass.
17
+ * Use the [fragment_1.newInstance] factory method to
18
+ * create an instance of this fragment.
19
+ */
20
+ class fragment_1 : Fragment() {
21
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
22
+ return inflater.inflate(R.layout.fragment_1, container, false)
23
+ }
24
+ }
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools"
4
+ android:layout_width="match_parent"
5
+ android:layout_height="match_parent"
6
+ android:background="#2196F3"
7
+ tools:context=".fragment_1">
8
+
9
+ <!-- TODO: Update blank fragment layout -->
10
+ <TextView
11
+ android:layout_width="wrap_content"
12
+ android:layout_height="wrap_content"
13
+ android:layout_gravity="center"
14
+ android:text="@string/hello_blank_fragment" />
15
+
16
+ </FrameLayout>
@@ -0,0 +1,17 @@
1
+ package com.example.fragments
2
+
3
+ import android.os.Bundle
4
+ import android.support.v4.app.Fragment
5
+ import android.view.LayoutInflater
6
+ import android.view.View
7
+ import android.view.ViewGroup
8
+
9
+ private const val ARG_PARAM1 = "param1"
10
+ private const val ARG_PARAM2 = "param2"
11
+
12
+ class fragment_2 : Fragment() {
13
+ // TODO: Rename and change types of parameters
14
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
15
+ return inflater.inflate(R.layout.fragment_2, container, false)
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools"
4
+ android:layout_width="match_parent"
5
+ android:layout_height="match_parent"
6
+ android:background="#FFEB3B"
7
+ tools:context=".fragment_2">
8
+
9
+ <!-- TODO: Update blank fragment layout -->
10
+ <TextView
11
+ android:layout_width="wrap_content"
12
+ android:layout_height="wrap_content"
13
+ android:layout_gravity="center"
14
+ android:text="@string/hello_blank_fragment" />
15
+
16
+ </FrameLayout>
@@ -0,0 +1 @@
1
+ java > fragment > blankfragment > automatic kt and its corresponding xml created
@@ -0,0 +1,26 @@
1
+ package com.example.menu
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.view.Menu
6
+ import android.view.MenuItem
7
+ import android.widget.Toast
8
+
9
+ class MainActivity : AppCompatActivity() {
10
+ override fun onCreate(savedInstanceState: Bundle?) {
11
+ super.onCreate(savedInstanceState)
12
+ setContentView(R.layout.activity_main)
13
+ }
14
+ override fun onCreateOptionsMenu(menu: Menu?): Boolean {
15
+ menuInflater.inflate(R.menu.menu_main,menu)
16
+ return super.onCreateOptionsMenu(menu)
17
+ }
18
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
19
+ when (item.itemId){
20
+ R.id.about -> Toast.makeText(this,"About Selected",Toast.LENGTH_SHORT).show()
21
+ R.id.settings -> Toast.makeText(this,"Settings Selected",Toast.LENGTH_SHORT).show()
22
+ R.id.exit -> Toast.makeText(this,"Exit Selected",Toast.LENGTH_SHORT).show()
23
+ }
24
+ return super.onOptionsItemSelected(item)
25
+ }
26
+ }
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context=".MainActivity">
8
+
9
+ <TextView
10
+ android:layout_width="wrap_content"
11
+ android:layout_height="wrap_content"
12
+ android:text="Hello World!"
13
+ app:layout_constraintBottom_toBottomOf="parent"
14
+ app:layout_constraintEnd_toEndOf="parent"
15
+ app:layout_constraintStart_toStartOf="parent"
16
+ app:layout_constraintTop_toTopOf="parent" />
17
+
18
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1 @@
1
+ java>new menu directory>new menu resource file named "menu_main.xml"
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <menu xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto">
4
+ <item
5
+ android:id="@+id/overflowMenu"
6
+ android:icon="@drawable/menu"
7
+ android:title=""
8
+ app:showAsAction="always">
9
+ <menu>
10
+ <item
11
+ android:id="@+id/settings"
12
+ android:icon="@drawable/setting"
13
+ android:title="SETTINGS"
14
+ app:showAsAction="never" />
15
+ <item
16
+ android:id="@+id/about"
17
+ android:icon="@drawable/about"
18
+ android:title="ABOUT"
19
+ app:showAsAction="never" />
20
+ <item
21
+ android:id="@+id/exit"
22
+ android:icon="@drawable/exit"
23
+ android:title="EXIT"
24
+ app:showAsAction="never" />
25
+ </menu>
26
+ </item>
27
+ </menu>
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "madbmsj",
3
+ "version": "2.2.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "type": "commonjs"
13
+ }
@@ -0,0 +1,49 @@
1
+ package com.example.menu
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.support.v7.widget.PopupMenu
6
+ import android.view.Menu
7
+ import android.view.MenuItem
8
+ import android.widget.Button
9
+ import android.widget.Toast
10
+
11
+ class MainActivity : AppCompatActivity() {
12
+ override fun onCreate(savedInstanceState: Bundle?) {
13
+ super.onCreate(savedInstanceState)
14
+ setContentView(R.layout.activity_main)
15
+
16
+ val B1 = findViewById<Button>(R.id.B1)
17
+ B1.setOnClickListener {
18
+ val popupMenu: PopupMenu = PopupMenu(this, B1)
19
+ popupMenu.menuInflater.inflate(R.menu.menu_main, popupMenu.menu)
20
+
21
+ // 02-05-2025 Rashmi R, iSE 23 (This line appears to be a comment/note, not code)
22
+
23
+ popupMenu.setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { item ->
24
+ when (item.itemId) {
25
+ R.id.item1 ->
26
+ Toast.makeText(
27
+ this@MainActivity,
28
+ "You Clicked : " + item.title,
29
+ Toast.LENGTH_SHORT
30
+ ).show()
31
+ R.id.item2 ->
32
+ Toast.makeText(
33
+ this@MainActivity,
34
+ "You Clicked : " + item.title,
35
+ Toast.LENGTH_SHORT
36
+ ).show()
37
+ R.id.item3 ->
38
+ Toast.makeText(
39
+ this@MainActivity,
40
+ "You Clicked : " + item.title,
41
+ Toast.LENGTH_SHORT
42
+ ).show()
43
+ }
44
+ true
45
+ })
46
+ popupMenu.show()
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context=".MainActivity">
8
+
9
+ <Button
10
+ android:id="@+id/B1"
11
+ android:layout_width="wrap_content"
12
+ android:layout_height="wrap_content"
13
+ android:text="Popup menu"
14
+ app:layout_constraintBottom_toBottomOf="parent"
15
+ app:layout_constraintEnd_toEndOf="parent"
16
+ app:layout_constraintStart_toStartOf="parent"
17
+ app:layout_constraintTop_toTopOf="parent" />
18
+
19
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1 @@
1
+ java>new menu directory>new menu resource file named "menu_main.xml"
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <menu xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto">
4
+ <item android:id="@+id/item1"
5
+ android:title="Open"
6
+ app:showAsAction="never"
7
+ />
8
+ <item android:id="@+id/item2"
9
+ android:title="Search"
10
+ app:showAsAction="never"
11
+ />
12
+ <item android:id="@+id/item3"
13
+ android:title="Exit"
14
+ app:showAsAction="never"
15
+ />
16
+ </menu>
@@ -0,0 +1,64 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:app="http://schemas.android.com/apk/res-auto"
5
+ xmlns:tools="http://schemas.android.com/tools"
6
+ android:layout_width="match_parent"
7
+ android:layout_height="match_parent"
8
+ tools:context=".MainActivity">
9
+ <EditText
10
+ android:id="@+id/ed1"
11
+ android:layout_width="wrap_content"
12
+ android:layout_height="wrap_content"
13
+ android:layout_marginTop="56dp"
14
+ android:ems="10"
15
+ android:hint="Username"
16
+ android:inputType="textPersonName"
17
+ android:minHeight="48dp"
18
+ app:layout_constraintEnd_toEndOf="parent"
19
+ app:layout_constraintHorizontal_bias="0.497"
20
+ app:layout_constraintStart_toStartOf="parent"
21
+ app:layout_constraintTop_toTopOf="parent" />
22
+ <EditText
23
+ android:id="@+id/ed2"
24
+ android:layout_width="wrap_content"
25
+ android:layout_height="wrap_content"
26
+ android:layout_marginTop="36dp"
27
+ android:ems="10"
28
+ android:hint="Password"
29
+ android:inputType="textPersonName"
30
+ android:minHeight="48dp"
31
+ app:layout_constraintEnd_toEndOf="parent"
32
+ app:layout_constraintHorizontal_bias="0.497"
33
+ app:layout_constraintStart_toStartOf="parent"
34
+ app:layout_constraintTop_toBottomOf="@+id/ed1" />
35
+
36
+ <Button
37
+ android:id="@+id/b1"
38
+ android:layout_width="wrap_content"
39
+ android:layout_height="wrap_content"
40
+ android:layout_marginTop="95dp"
41
+ android:text="Save"
42
+ app:layout_constraintEnd_toEndOf="parent"
43
+ app:layout_constraintHorizontal_bias="0.235"
44
+ app:layout_constraintStart_toStartOf="parent"
45
+ app:layout_constraintTop_toBottomOf="@+id/ed2" />
46
+ <Button
47
+ android:id="@+id/b2"
48
+ android:layout_width="wrap_content"
49
+ android:layout_height="wrap_content"
50
+ android:layout_marginStart="96dp"
51
+ android:layout_marginTop="95dp"
52
+ android:text="Load"
53
+ app:layout_constraintStart_toEndOf="@+id/b1"
54
+ app:layout_constraintTop_toBottomOf="@+id/ed2" />
55
+ <Button
56
+ android:id="@+id/b4"
57
+ android:layout_width="wrap_content"
58
+ android:layout_height="wrap_content"
59
+ android:layout_marginTop="20dp"
60
+ android:layout_marginEnd="68dp"
61
+ android:text="DELETE"
62
+ app:layout_constraintEnd_toEndOf="parent"
63
+ app:layout_constraintTop_toBottomOf="@+id/b2" />
64
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1,47 @@
1
+ package com.example.sharedpref
2
+
3
+ import android.content.Context
4
+ import android.support.v7.app.AppCompatActivity
5
+ import android.os.Bundle
6
+ import android.widget.Button
7
+ import android.widget.EditText
8
+ import android.widget.Toast
9
+
10
+ class MainActivity : AppCompatActivity() {
11
+ override fun onCreate(savedInstanceState: Bundle?) {
12
+ super.onCreate(savedInstanceState)
13
+ setContentView(R.layout.activity_main)
14
+
15
+ val name = findViewById<EditText>(R.id.ed1)
16
+ val password = findViewById<EditText>(R.id.ed2)
17
+ val save = findViewById<Button>(R.id.b1)
18
+ val load = findViewById<Button>(R.id.b2)
19
+ val del = findViewById<Button>(R.id.b4)
20
+
21
+ // Instantiate SharedPreferences
22
+ val sharedPref = getSharedPreferences("addName", Context.MODE_PRIVATE)
23
+ val edit = sharedPref.edit()
24
+
25
+ // Save data
26
+ save.setOnClickListener {
27
+ edit.putString("name", name.text.toString())
28
+ edit.putString("password", password.text.toString())
29
+ edit.commit()
30
+ Toast.makeText(this, "Data Saved", Toast.LENGTH_LONG).show()
31
+ }
32
+
33
+ // Load data
34
+ load.setOnClickListener {
35
+ val getName = sharedPref.getString("name", "default value")
36
+ val getPass = sharedPref.getString("password", "default value")
37
+ Toast.makeText(this, "$getName $getPass", Toast.LENGTH_LONG).show()
38
+ }
39
+
40
+ // Delete data
41
+ del.setOnClickListener {
42
+ edit.clear()
43
+ edit.commit()
44
+ Toast.makeText(this, "Data Cleared", Toast.LENGTH_SHORT).show()
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools"
4
+ android:layout_width="match_parent"
5
+ android:layout_height="match_parent"
6
+ tools:context=".MainActivity"
7
+ tools:ignore="HardcodedText">
8
+
9
+ <TextView
10
+ android:id="@+id/textview"
11
+ android:layout_width="wrap_content"
12
+ android:layout_height="wrap_content"
13
+ android:layout_centerHorizontal="true"
14
+ android:layout_marginTop="32dp"
15
+ android:text="Shared Preferences"
16
+ android:textColor="@android:color/black"
17
+ android:textSize="24sp" />
18
+
19
+ <EditText
20
+ android:id="@+id/ed1"
21
+ android:layout_width="match_parent"
22
+ android:layout_height="wrap_content"
23
+ android:layout_below="@id/textview"
24
+ android:layout_marginStart="16dp"
25
+ android:layout_marginTop="16dp"
26
+ android:layout_marginEnd="16dp"
27
+ android:hint="Enter your Name"
28
+ android:padding="10dp" />
29
+
30
+ <EditText
31
+ android:id="@+id/ed2"
32
+ android:layout_width="match_parent"
33
+ android:layout_height="wrap_content"
34
+ android:layout_below="@id/ed1"
35
+ android:layout_marginStart="16dp"
36
+ android:layout_marginTop="16dp"
37
+ android:layout_marginEnd="16dp"
38
+ android:hint="Enter your Age"
39
+ android:inputType="number"
40
+ android:padding="10dp" />
41
+
42
+
43
+
44
+ </RelativeLayout>
@@ -0,0 +1,57 @@
1
+ package com.example.sharedpref2
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.widget.EditText
6
+
7
+
8
+ class MainActivity : AppCompatActivity() {
9
+
10
+ private lateinit var name: EditText
11
+ private lateinit var age: EditText
12
+
13
+ override fun onCreate(savedInstanceState: Bundle?) {
14
+ super.onCreate(savedInstanceState)
15
+ setContentView(R.layout.activity_main)
16
+
17
+ name = findViewById(R.id.ed1)
18
+ age = findViewById(R.id.ed2)
19
+ }
20
+
21
+ // Fetch the stored data in onResume()
22
+ // Because this is what will be called when the app opens again
23
+ override fun onResume() {
24
+ super.onResume()
25
+
26
+ // Fetching the stored data from SharedPreferences
27
+ val sh = getSharedPreferences("MySharedPref", MODE_PRIVATE)
28
+
29
+ val s1 = sh.getString("name", "")
30
+ val a = sh.getInt("age", 0)
31
+
32
+ // Setting the fetched data in the EditTexts
33
+ name.setText(s1)
34
+ age.setText(a.toString())
35
+ }
36
+
37
+ // Store the data in SharedPreferences in the onPause()
38
+ // This method is called when the user closes the application
39
+ override fun onPause() {
40
+ super.onPause()
41
+
42
+ // Creating a SharedPreferences object
43
+ val sharedPreferences = getSharedPreferences("MySharedPref", MODE_PRIVATE)
44
+ val myEdit = sharedPreferences.edit()
45
+
46
+ // Writing user data to SharedPreferences
47
+ myEdit.putString("name", name.text.toString())
48
+
49
+ // Safely parsing age input
50
+ val ageText = age.text.toString()
51
+ val ageInt = ageText.toIntOrNull() ?: 0
52
+ myEdit.putInt("age", ageInt)
53
+
54
+ // Applying changes
55
+ myEdit.apply()
56
+ }
57
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: androidd
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A package containing the androidd folder.
5
5
  Home-page: https://github.com/yourusername/androidd
6
6
  Author: Your Name