Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following is an example of Android with sqlite. It is very useful for beginner. Example contains ListActivity instead if Spinner. Just learn the example properly and you can make changes according your requirements. </p> <pre><code>public class CRUDonDB extends ListActivity { private final String SAMPLE_DB_NAME = "myFriendsDb"; private final String SAMPLE_TABLE_NAME = "friends"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayList&lt;String&gt; results = new ArrayList&lt;String&gt;(); SQLiteDatabase sampleDB = null; try { sampleDB = this.openOrCreateDatabase(SAMPLE_DB_NAME, MODE_PRIVATE, null); sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " + SAMPLE_TABLE_NAME + " (LastName VARCHAR, FirstName VARCHAR," + " Country VARCHAR, Age INT(3));"); sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAME + " Values ('Makam','Sai Geetha','India',25);"); sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAME + " Values ('Chittur','Raman','India',25);"); sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAME + " Values ('Solutions','Collabera','India',20);"); Cursor c = sampleDB.rawQuery("SELECT FirstName, Age FROM " + SAMPLE_TABLE_NAME + " where Age &gt; 10 LIMIT 5", null); if (c != null ) { if (c.moveToFirst()) { do { String firstName = c.getString(c.getColumnIndex("FirstName")); int age = c.getInt(c.getColumnIndex("Age")); results.add("" + firstName + ",Age: " + age); }while (c.moveToNext()); } } this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,results)); } catch (SQLiteException se ) { Log.e(getClass().getSimpleName(), "Could not create or Open the database"); } finally { if (sampleDB != null) sampleDB.execSQL("DELETE FROM " + SAMPLE_TABLE_NAME); sampleDB.close(); } } } </code></pre> <p>Also have a look at this <a href="http://www.mydoople.com/android-spinner-example" rel="nofollow">Spinner Example</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload