Android Spinner get data From SQLite Database

Last Tutorial about Spinner Android Working with Spinner was having static data.In this Tutorial we will getting data from database dynamically. So Let's Start 1.Open Eclipse or Android Studio -> New Project->Android Application Project-> Name of Application-> Follow all instructions and complete by clicking on Finish. 2.Create Layout for MainActivity.java that will be our mainscreen activity_main.xml <LinearLayout … Continue reading Android Spinner get data From SQLite Database

Android SQLite Database Example

MainActivity.java MainActivity.java package com.androidruler.databasesample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { ListView allcontacts; TextView totalcontacts; ArrayList<String> allusers=new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); allcontacts=(ListView)findViewById(R.id.contactlist); totalcontacts=(TextView)findViewById(R.id.totalcount); DbHandler db=new DbHandler(MainActivity.this); //inserting contacts db.addContact(new Contact("Ankur","Bansal","123456789")); db.addContact(new Contact("Vibhor","Tayal","267755557")); db.addContact(new … Continue reading Android SQLite Database Example