Back to project page Android---using-SQLite-Database---Sample--Code.
The source code is released under:
This Code base is Open Source and Anyone with access to this can use it. The App Guruz is not responsible in Any way.
If you think the Android project Android---using-SQLite-Database---Sample--Code listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.tag.androidsqlite; /*from www . ja v a2s .co m*/ import java.util.List; import com.tag.androidsqlite.R; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class AndroidSQLiteTutorialActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); DatabaseHandler db = new DatabaseHandler(this); /** * CRUD Operations * */ // Inserting Contacts Log.d("Insert: ", "Inserting .."); db.addContact(new Contact("Ravi", "9100000000")); db.addContact(new Contact("Srinivas", "9199999999")); db.addContact(new Contact("Tommy", "9522222222")); db.addContact(new Contact("Karthik", "9533333333")); // Reading all contacts Log.d("Reading: ", "Reading all contacts.."); List<Contact> contacts = db.getAllContacts(); for (Contact cn : contacts) { String log = "Id: " + cn.getID() + " ,Name: " + cn.getName() + " ,Phone: " + cn.getPhoneNumber(); // Writing Contacts to log Log.d("Name: ", log); } } }