Classicnewcar.us


What are the different Agile Testing Methodology? Test

What are the different Agile Testing Methodology? Test

In this article, we will see an example of SQLite Insert Example. We will work on database list application to demonstrate the SQLite insert.In our previous article on Android, I showed you how to implement search. We will work on the same example to add an ‘Add’ button to the action bar.We want to add a button to the action bar, clicking which should open a dialog with a custom view. The custom view will contain just one edit field where we will enter the language name and then an ‘Add’ button to insert the language to the database table.menu/main.xml:When we click on the ‘Add’ button in the action bar, we will show the language field in a dialog box. The dialog view will have language and the ‘Add’ button. Here is the custom dialog view. This will be set to the AlertDialog as we build it.activity_add_item.xml.xml:We have added the ‘Add’ button to the action bar. When the button is clicked it should open up the AlertDialog. We will override method onOptionsItemSelected() to create the DialogFragment and show it. We need to hook in the creation of AlertDialog in the onCreateDialog() method of DialogFragment .LanguageListActivity:See Android Custom Dialog Example to know more about how to create and show a custom dialog. Few points to note about:AddItemDialogFragment:We initialize the Database as the application starts.MyApplication:SQLiteOpenHelper is Android’s SQLite helper class to create database and inserts some languages.SQLiteHelper:DatabaseConstants:Insert is handled in ContentProvider.insert(). The values to be inserted come in the form of ContentValues value object. Next, we open the database in writable mode and then call on SQLiteDatabase.insert() to insert data.LanguageContentProvider:We register ContentProvider in <provider> element.androidManifest.xml:Language List Page with Add ButtonAdd Language DialogEnter Language and click on AddLanguage InsertedCannot insert same language againLanguage added to the listThis was an example about Android SQLite Database Insert Example.Ram's expertise lies in test driven development and re-factoring. He is passionate about open source technologies and loves blogging on various java and open-source technologies like spring. You can reach him at [email protected]Comments are closed.







#Contact US #Terms of Use #Privacy Policy #Earnings Disclaimer