I am new to android. I would like to create a database that will contain a name and phone number. I need to add in this database or to modify the phone number element.
Can someone please help me with creating a table with this two elements in database and check if a specific name exists. If no I want to create add add it in the table. If the name exists I want to be able to modify the phoe number. I want to create the table just once. I think I also need to check if the table is created or no.
Can someone give me a full android example with instantiate, create, insert, delete or modify or search elements in a database? Please?
Appreciate,. Thank you
Based on the example with the student database (http://androidpartaker.wordpress.com/2011/07/03/introduction-to-android-sqlite-database)
I have:
if (cursor != null) {
while (cursor.moveToNext()) {
if (cursor.getString(1).equals("me")) value=i;
Log.i("Student", "Student Name: " + cursor.getString(1)
+ " Grade " + cursor.getString(2));
i=i+1;
}
}
Cursor cursor1 = dbUtil1.fetchStudent(value);
if (cursor1 != null) {
//while (cursor1.moveToNext())
{
Toast.makeText(this, "Student "+ "Student Name: " + cursor1.getString(1)
+ " Grade " + cursor1.getString(2),Toast.LENGTH_LONG).show();
//i=i+1;
}
}
but is not working properly. where am I wrong?
Here is a very good introduction to Android SQLite database via a sample application : http://androidpartaker.wordpress.com/2011/07/03/introduction-to-android-sqlite-database/