Android Essay (i)

Source: Internet
Author: User

One. SQLite database
* 1. Business
BeginTransaction (); Start a transaction
Settransactionsuccessful (); Set the success point, at the end of the transaction, the action before the success point is committed
Endtransaction (); Ends a transaction, usually in finally, if the close transaction is not displayed, the time-out is also turned off, but less efficient
* 2. Another addition and deletion change
The Sqlitedatabase class has insert (), delete (), update (), query () Four methods, without writing SQL statements, by assembling parameters to get SQL
Usually used in ContentProvider

Two. ListView
1. Three kinds of adapter build ListView
When adding entries to the ListView, you can use the Setadapter (ListAdapter) method, which has three common listadapter
Baseadapter: Defines a class that inherits Baseadapter, overrides 4 abstract methods, and the ListView entry is built by the GetView () method
Simpleadapter: When you create a Simpleadapter object, the data is passed in (list<map<string,?>>) and the binding relationship of the data is specified
Simplecursoradapter: When creating a Simplecursoradapter object, pass in a cursor, specifying the binding relationship of the data
2. Monitor the ListView click
Call the Listview.setonitemclicklistener (Onitemclicklistener) method to register a listener
Use the Parent.getitematposition (position) method in the listener's Onitemclick () method to get the data on the specified entry
Baseadapter: Returns the data returned in the custom GetItem () method
Simpleadapter: A map is returned, which is a map in the list when the Simpleadapter is created
Simplecursoradapter: A cursor is returned, which is the cursor that was passed in when it was created, but has been assigned to the clicked Index through the Movetoposition () method.

Three. Content provider (ContentProvider)
1. What is ContentProvider
ContentProvider can be used to share the data in the program, to provide the method of adding and deleting.
ContentProvider can register the Observer, monitor the change of the data
* 2. How to create
Defining class inheritance ContentProvider, implementing abstract methods
Registering in the manifest file
3. Register on the phone
Install the app on your phone without running the program
* 4. How to access
Gets the parser contentresolver, specifying the URI
Access URI-associated ContentProvider by Contentresolver.insert (), delete (), update (), query () method
Processing of 5.Uri
Use Urimatcher to check if the incoming URI matches the specified match
If the URI has an ID, you can use Contenturis to get the ID, and the insertion method can use Contenturis to add an ID to the URI

Android Essay (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.