Hello Android fellows… let us Retrieve today
I mean lets learn how to retrieve data from a SQLite database in Android. This is the second part of the SQLite blog series. In my previous post I have shown you how to insert data to a SQLite database. I am continuing from there. So please have a look on my previous post before you go through this post directly.
If you guys can remember, you did not able to see anything when we started our undergraduate GPA Android application last time. But after coding to retrieve data form the SQLite database, you will be able to see the existing or the registered undergraduates’ names in our first UI (User Interface) as shown below.
Hey… you can only see names of the undergraduates. What happen to the other details? :O Don’t worry and don’t be hurry, you can see those details when you click on a name of an undergraduate as in Figure 2
Enough fancy stories. Let me explain the logic and the techniques behind this. The basic logic is similar to what we have done when we inserting data. That means to contact the database we need a helper class which extends the SQLiteOpenHelper class. Then we need a readable SQLite database. If you can remember my previous post, there we have used a writable database because we wanted to insert data. But today we are going to retrieve data.
OK, now we have a SQLite database that can be read. How are we going to read it? Cursor class will give you a hand to fulfill your target. By using a while loop, we can traverse each and every raw of the particular table. Lets look at the code now. The comment in the code is more clear than the explanation here, because I have explain almost all the lines with comments.
package com.anuja.sqlite;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class UndergraduateListActivity extends Activity implements OnClickListener, OnItemClickListener {
private ListView uGraduateNamesListView;
private Button addNewUndergraduateButton;
// We need some kind of Adapter to made the connection between ListView UI component and SQLite data set.
private ListAdapter uGraduateListAdapter;
// We need this while we read the query using Cursor and pass data
private ArrayList<UndergraduateDetailsPojo> pojoArrayList;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.names_listview);
// Initialize UI components
uGraduateNamesListView = (ListView) findViewById(R.id.uGraduateListView);
uGraduateNamesListView.setOnItemClickListener(this);
addNewUndergraduateButton = (Button) findViewById(R.id.namesListViewAddButton);
addNewUndergraduateButton.setOnClickListener(this);
pojoArrayList = new ArrayList<UndergraduateDetailsPojo>();
// For the third argument, we need a List that contains Strings.
//We decided to display undergraduates names on the ListView.
//Therefore we need to create List that contains undergraduates names
uGraduateListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
uGraduateNamesListView.setAdapter(uGraduateListAdapter);
}
@Override
public void onClick(View v) {
Intent addNewUndergraduateIntent = new Intent(this, AddNewUndergraduateActivity.class);
startActivity(addNewUndergraduateIntent);
}
// To create a List that contains undergraduate names, we have to read the SQLite database
//We are going to do it in the separate method
public List<String> populateList(){
// We have to return a List which contains only String values. Lets create a List first
List<String> uGraduateNamesList = new ArrayList<String>();
// First we need to make contact with the database we have created using the DbHelper class
AndroidOpenDbHelper openHelperClass = new AndroidOpenDbHelper(this);
// Then we need to get a readable database
SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
// We need a a guy to read the database query. Cursor interface will do it for us
//(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
Cursor cursor = sqliteDatabase.query(AndroidOpenDbHelper.TABLE_NAME_GPA, null, null, null, null, null, null);
// Above given query, read all the columns and fields of the table
startManagingCursor(cursor);
// Cursor object read all the fields. So we make sure to check it will not miss any by looping through a while loop
while (cursor.moveToNext()) {
// In one loop, cursor read one undergraduate all details
// Assume, we also need to see all the details of each and every undergraduate
// What we have to do is in each loop, read all the values, pass them to the POJO class
//and create a ArrayList of undergraduates
String ugName = cursor.getString(cursor.getColumnIndex(AndroidOpenDbHelper.COLUMN_NAME_UNDERGRADUATE_NAME));
String ugUniId = cursor.getString(cursor.getColumnIndex(AndroidOpenDbHelper.COLUMN_NAME_UNDERGRADUATE_UNI_ID));
double ugGpa = cursor.getDouble(cursor.getColumnIndex(AndroidOpenDbHelper.COLLUMN_NAME_UNDERGRADUATE_GPA));
// Finish reading one raw, now we have to pass them to the POJO
UndergraduateDetailsPojo ugPojoClass = new UndergraduateDetailsPojo();
ugPojoClass.setuGraduateName(ugName);
ugPojoClass.setuGraduateUniId(ugUniId);
ugPojoClass.setuGraduateGpa(ugGpa);
// Lets pass that POJO to our ArrayList which contains undergraduates as type
pojoArrayList.add(ugPojoClass);
// But we need a List of String to display in the ListView also.
//That is why we create "uGraduateNamesList"
uGraduateNamesList.add(ugName);
}
// If you don't close the database, you will get an error
sqliteDatabase.close();
return uGraduateNamesList;
}
// If you don't write the following code, you wont be able to see what you have just insert to the database
@Override
protected void onResume() {
super.onResume();
uGraduateListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, populateList());
uGraduateNamesListView.setAdapter(uGraduateListAdapter);
}
// On ListView you just see the name of the undergraduate, not any other details
// Here we provide the solution to that. When the user click on a list item, he will redirect to a page where
//he can see all the details of the undergraduate
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getApplicationContext(), "Clicked on :" + arg2, Toast.LENGTH_SHORT).show();
// We want to redirect to another Activity when the user click an item on the ListView
Intent updateDeleteUgraduateIntent = new Intent(this, UpdateDeleteUndergraduateActivity.class);
// We have to identify what object, does the user clicked, because we are going to pass only clicked object details to the next activity
// What we are going to do is, get the ID of the clicked item and get the values from the ArrayList which has
//same array id.
UndergraduateDetailsPojo clickedObject = pojoArrayList.get(arg2);
// We have to bundle the data, which we want to pass to the other activity from this activity
Bundle dataBundle = new Bundle();
dataBundle.putString("clickedUgraduateName", clickedObject.getuGraduateName());
dataBundle.putString("clickedUgraduateUniId", clickedObject.getuGraduateUniId());
dataBundle.putDouble("clickedUgraduateGpa", clickedObject.getuGraduateGpa());
// Attach the bundled data to the intent
updateDeleteUgraduateIntent.putExtras(dataBundle);
// Start the Activity
startActivity(updateDeleteUgraduateIntent);
}
}
Above is the full code for retrieve. I will explain the scenario from where I have stopped. Now you have the data set which we have read from the SQLite database. You have a ListView that you can visualize the out put to the user. You can combine the UI component and the data set by using an Adapter. Here I have used an ArrayAdapter.
Figure 2 relate with a new Activity. You can see, that I have call a new Activity with in the OnItemClick method. Those things I have covered in my previous blogs. Therefore don’t ask me to repeat it here
I think this is more than enough for today’s blog post. I will upload the source code to GitHub after completing Update and Delete functions as well.
Wish all of you a Merry Christmas…!!!


i want to know about your UpdateDeleteUndergraduateActivity.
help me !
Hi Nayak,
It is an Activity class. Therefore you should have an XML layout relate to that class. Figure 2 shows the UI for that layout. What I have done in the background is getting the Bundle content and set the values of the EditText fields accordingly. If you have no idea how to use Bundle class, please go through this post (http://anujarosha.wordpress.com/2011/03/07/how-to-get-the-content-that-user-type-in-a-edittext-field-in-one-activity-to-another-activity-in-android/)
I will upload the full source code to GitHub after I have completed the Update and Delete function blog post.
Good luck…
Hi,
Thanks for the article. When will the source code be available?
Hi & Thank’s Anujarosha,
I want to know that if someone wants to delete some name with related information from the LISTview and automatic row updation means rows without any gap of blank row .how we could do that .
help me !
thanks in advance……
Hi Nayak,
You are asking about Delete function which is going to be my next blog post
I will definitely show you the source code. Till then take an effort. I’ll give you a hint. Removing an item in the middle of the ListView means, removing that items’ whole data from the SQLite database.
- Put a Delete button in the XML file in Figure 2
- Get values given in the EditText fields
- Use SQLiteOpenHelper
- Use SQLiteDatabase
- String[] for whereClauseArgument
- Finally use the delete query
Good luck…!!!
hi my code is fine on the emulator but when i used the api file on real device it will not show the retriving data of database
hi Kirti,
I have checked the source again with a device.
Model : Acer A500
Android Version : 3.2.1
It is working for me. Can you please send me more details about your issue?
hi
Is thair any setting have to do on my android phone to show the data of database.When i used to installed the apk file into my android phone.It was not displayed any data of database.
hi Kirti,
As far as I know, you no need to do any kind of settings. We retrieve data using our own application. You can’t see the raw database just like we can see in phpMyAdmin in your REAL device. But you can see in the emulator with the help of SQLite browser.
hi thnks
i got the problem i was thought that it used static database table on every device that,s why i did not insert the values by using the edit text & because of that the the value was that shown. actually i want to used the staic data everywhere.
Hi,
I got a problem when adding more columns saying dat no column inserted when I have specified that column. Can you provide your email address so that I can attach the database file, I would be grateful if you can look at it and see what the issues is. I have researched but unable to find the solution.
Hello,
I am using SQlite Browser to create data and insert data manually. now i want to retrive data from my table. I got error again and again. i am new in android. can u help me please.
Hi Shipra,
Post your Error or more detials about your error. We will try to solve that. You said that you have insert data to the database using SQLite browser. Hope you have push that file back to the device/emulator before you run your code in Android.
Awesome tutorial. Good job!!!
Thank you… Dee …
hi anujarosha’
nice tutorial. but i hav a prob.. when i tried the code it gave me errors. as is the activity terminates on starting..
can u help mi please.
package com.pollyroid;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
public class display_quest extends Activity implements OnClickListener {
private ListView questlist;
private Button Button1;
// We need some kind of Adapter to made the connection between ListView UI component and SQLite data set.
private ListAdapter ListAdapter;
// We need this while we read the query using Cursor and pass data
private ArrayList pojoArrayList;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.display_quest);
Button1 = (Button) findViewById(R.id.button1);
Button1.setOnClickListener(this);
pojoArrayList = new ArrayList();
// For the third argument, we need a List that contains Strings.
//We decided to display undergraduates names on the ListView.
//Therefore we need to create List that contains undergraduates names
ListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, populateList());
questlist.setAdapter(ListAdapter);
}
@Override
public void onClick(View v) {
Intent inte2 = new Intent(this, Create_poll.class);
startActivity(inte2);
}
// To create a List that contains questions, we have to read the SQLite database
//We are going to do it in the separate method
public List populateList(){
// We have to return a List which contains only String values. Lets create a List first
List questlist = new ArrayList();
// First we need to make contact with the database we have created using the DbHelper class
AndroidOpenDbHelper openHelperClass = new AndroidOpenDbHelper(this);
// Then we need to get a readable database
SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
// We need a a guy to read the database query. Cursor interface will do it for us
//(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
Cursor cursor = sqliteDatabase.query(AndroidOpenDbHelper.TABLE_NAME, null, null, null, null, null, null);
// Above given query, read all the columns and fields of the table
startManagingCursor(cursor);
// Cursor object read all the fields. So we make sure to check it will not miss any by looping through a while loop
while (cursor.moveToNext()) {
// In one loop, cursor read one quest all details
// Assume, we also need to see all the details of each and every quest
// What we have to do is in each loop, read all the values, pass them to the POJO class
//and create a ArrayList of quest
String quest = cursor.getString(cursor.getColumnIndex(AndroidOpenDbHelper.COLUMN_NAME_QUEST));
String option1 = cursor.getString(cursor.getColumnIndex(AndroidOpenDbHelper.COLUMN_NAME_OPTION1));
String option2 = cursor.getString(cursor.getColumnIndex(AndroidOpenDbHelper.COLLUMN_NAME_OPTION2));
// Finish reading one raw, now we have to pass them to the POJO
DetailsPojo PojoClass = new DetailsPojo();
PojoClass.setquest(quest);
PojoClass.setoption1(option1);
PojoClass.setoption2(option2);
// Lets pass that POJO to our ArrayList which contains quest as type
pojoArrayList.add(PojoClass);
// But we need a List of String to display in the ListView also.
//That is why we create “questlist”
questlist.add(quest);
}
// If you don’t close the database, you will get an error
sqliteDatabase.close();
return questlist;
}
// If you don’t write the following code, you wont be able to see what you have just insert to the database
@Override
protected void onResume() {
super.onResume();
pojoArrayList = new ArrayList();
ListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, populateList());
questlist.setAdapter(ListAdapter);
}
@Override
protected void onStart() {
super.onStart();
pojoArrayList = new ArrayList();
ListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, populateList());
questlist.setAdapter(ListAdapter);
}
}
Hello Anisha,
Submit your error in LogCat. It will help me to identify the error line.
Furthermore please concentrate the JAVA conventions even though they are not producing errors.
03-27 07:37:15.559: D/AndroidRuntime(282): Shutting down VM
03-27 07:37:15.559: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-27 07:37:15.579: E/AndroidRuntime(282): FATAL EXCEPTION: main
03-27 07:37:15.579: E/AndroidRuntime(282): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pollyroid/com.pollyroid.display_quest}: java.lang.NullPointerException
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.os.Handler.dispatchMessage(Handler.java:99)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.os.Looper.loop(Looper.java:123)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-27 07:37:15.579: E/AndroidRuntime(282): at java.lang.reflect.Method.invokeNative(Native Method)
03-27 07:37:15.579: E/AndroidRuntime(282): at java.lang.reflect.Method.invoke(Method.java:521)
03-27 07:37:15.579: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-27 07:37:15.579: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-27 07:37:15.579: E/AndroidRuntime(282): at dalvik.system.NativeStart.main(Native Method)
03-27 07:37:15.579: E/AndroidRuntime(282): Caused by: java.lang.NullPointerException
03-27 07:37:15.579: E/AndroidRuntime(282): at com.pollyroid.display_quest.onCreate(display_quest.java:39)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-27 07:37:15.579: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-27 07:37:15.579: E/AndroidRuntime(282): … 11 more
Hey Anisha,
Look at the following lines in LogCat out-put.
…
03-27 07:37:15.579: E/AndroidRuntime(282): Caused by: java.lang.NullPointerException
03-27 07:37:15.579: E/AndroidRuntime(282): at com.pollyroid.display_quest.onCreate(display_quest.java:39)
…
When you click on the last line of the above two mentioned lines, you will be redirect to the line where you get the NullPointerException. Another way is, go to the mentioned code line. In this scenario it is line 39. But when I copy your code in the IDE and check what is in the line 39, it shows me the comments which is something that wont make errors.
Things I have noticed are, you have to check whether you get the result from the SQLite database. “ListAdapter” is a default Android class and you have made a variable from that exact name. Please replace first letter with simple “l”. You will get NullPointerException when your ArrayList is empty. So check whether your Array is filled with data.
Good luck…!!!
Hey Anisha, I am just following code for an error I am getting. Where are you creating DetailsPojo in your code?
Is it possible for you to upload the xml for the listview? I’m unsure of some your “initialize ui elements”
hey thanks a lot…. it finaallly worked…!:)
Hey Anisha,
You are welcome
Hi m also getting the same error bt i cant debug it…………. plsssssssssss send me the full source code including xml and manifest file to dis mail id diwakar.ds13@yahoo.com……….. pls pls pls
Thnx a lot
unable to retreive the data…insertion is working fine..bt unable to retreive…Nothing is bein displayed in the emmulator…cn u help??
Hey i gt it rght…thr ws prob wth manifest file..
Hey send me the full code please to dis mail id……….. Diwakar.ds13@yahoo.com………….
Thnx……….
Can you please send me the full codes too??.. I need it badly .. Thanks in a million..
akiville23@gmail.com
Can you pls also send me the full source code? Thanks.
deanslaw@hotmail.com
Would you please post the link of the source code at GitHub for everyone to use?
Would be very grateful. Thanks
All right, Good one, but what to do if we want to show multiple TextViews inside the Listview using Sqlite, How can we achieve that?
Thanks a lot .. It was really helpful
Hi Anujarosha,Ur blog had helped me a lot. Thanks a lot…But I had one question.
Instead of using the sqlite database, can we use a remote or a server database..? If yes, how can we do the same insertions, updations and deletions with such a remote database. And the searching has to be done from the android mobile..Please help me…
i cant retrive values from my database as i used array adapter to insert values
Awesome blog…Thanks anuja..!!
In this line:
arrivalListAdapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1,populateList());
This line is perfect, but what if I have to introduce my custom adapter with my own layout (I donot want default layout) in this step, how will it be written?? Please help.
Hi Girish,
I’ll just give you some hints because I’m writing this reply in a rush. You can create your own Adapter class. But that class may extends appropriate ***Adapter class. As an example, if you are having an ExpandableList, you have to extends ExpandableListAdapter.
You can have your own layout. Just check LayoutInflater class, View class and inflate() method.
Good luck
E/Database(526): Error inserting undergraduate_name_column=SNEHA undergraduate_uni_id_column=ptwmjg
E/Database(526): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
E/Database(526): at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
E/Database(526): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
E/Database(526): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1582)E/Database(526): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
E/Database(526): at com.sneha.addnewnumber.AddNewUndergraduateActivity.insertUndergraduate(AddNewUndergraduateActivity.java:88)
E/Database(526): at com.sneha.addnewnumber.AddNewUndergraduateActivity.onClick(AddNewUndergraduateActivity.java:65)
E/Database(526): at android.view.View.performClick(View.java:2485)
E/Database(526): at android.view.View$PerformClick.run(View.java:9080)
E/Database(526): at android.os.Handler.handleCallback(Handler.java:587)
E/Database(526): at android.os.Handler.dispatchMessage(Handler.java:92)
E/Database(526): at android.os.Looper.loop(Looper.java:123)
E/Database(526): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/Database(526): at java.lang.reflect.Method.invokeNative(Native Method)
E/Database(526): at java.lang.reflect.Method.invoke(Method.java:507)
E/Database(526): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/Database(526): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/Database(526): at dalvik.system.NativeStart.main(Native Method)
I justuse ur code as it is..stil dis error…
plz solve dis..
plz send me whole combined code of inserting and retreiving data wid xml file..m unsure if m doin rite or not??
Hi m also getting the same error bt i cant debug it…………. plsssssssssss send me the full source code including xml and manifest file to dis mail id heer.sharma21@gmail.com……….. pls pls pls
Thnx a lot
For everybody who are asking for XML,
It is not a big deal for me to upload the XML files to GitHub. But what I think is, a good programmer is NOT a person who just copy and paste others’ code without understanding the concept. I have posted the UI and also all the logic codes that important to this application which is more than enough for the people who wants to learn something
Good luck…
thank u for ur rply.. bt i hv completed d code a month ago..
bt again thanx…
Hi…. nice tutorial…. it helped me a lot …
pls tell me how to retrieve data from database using a particular field … for example if i wnt to view only ece students detail using spinner r search box…. and the details of ece students should be view on listview …. pls help me ….
pls send source code to my mail id vaishu.sylph@gmail.com …. im waiting for ur reply …
thanks in advance….
please help me to get values of field that is in database declared as string but set method of that field accept list
Hi Rekha,
Not clear about your question. Please explain more.
hi!!
i am working on a project regarding feedback of students..
i need to create a database insert values and display a few fields when needed in listview. I have defined a class dbhelper in which database is created n my main activity have tried to retrieve the data.
the code doesnt show any error but when i tried running the app..its giving an error an force closing..
pls help me!!
Hi, i want to put more than uGraduateName in the listview?
for example the GPA also must be in the listview.. in the sub item.
Hi anujarosha , i wanted to retrieve the particular values from my database after matching ‘name’ column parameter. But am unable to retrieve it.could you please help me.My code is,
ClientInfoAct.java
package com.me.android.placefinder;
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class ClientInfoAct extends Activity {
Intent i;
EditText et,et1,et2,et3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_client_info);
}
public void enter(View v){
et=(EditText)findViewById(R.id.name1);
et1=(EditText)findViewById(R.id.n1);
et2=(EditText)findViewById(R.id.c1);
et3=(EditText)findViewById(R.id.a1);
DBConn helper=new DBConn(getApplicationContext(),”MyPFDB”,null,1);
ArrayListmyNames=helper.getNames();
for(String s:myNames){
if(s.equals(et.getText().toString())){
et1.setText(s);
//PLEASE HELP ME OVER HERE HOW TO RETRIEVE ‘NUMBER’ AND ‘ADDRESS’ VALUES OF MATCHING ‘NAME’.
}
}
}
public void deleteCon(View v){
et=(EditText)findViewById(R.id.name1);
DBConn helper=new DBConn(getApplicationContext(),”MyPFDB”,null,1);
helper.deleteContact(et.getText().toString());
ArrayListmyNames=helper.getNames();
for(String a:myNames){
Toast.makeText(getApplicationContext(), a, Toast.LENGTH_LONG).show();
}
}
}
//i want to display retrieved values in edit texts after entering name.
activity_client_info.xml
hai..thanks for the tutorial..but i have face a problem when i want to add the details..first when i’m still not put this retrieved code..i’ve no problem with adding..but when i used retrieved code..i can’t add any info..please help me!
hey anuja..i have used your tutorial but the problem is the database is not there..means the database is not created..can u please help me
Hi Anujarosha,Your blog is very helpful, Thanks a lot… can u please help me how to retrieve images from SQLite database…? If yes, how can we do the same insertions, updations and deletions with such database. And the searching has to be done from the android mobile..Please help me…
Thanks for your valuable job man……………..Thanks once again