Steps to prepare and use ContentProvicer

2011-05-26  来源:本站原创  分类:Mobile  人气:50 

Write:

1. Write a class, inheritance android.content.ContentProvider
2. Define a uri string, for example:

private static final String MY_URI = "com.test.dataContentProvider";

3. You can define a path corresponding to the code, when the match is successful, will return this code, we use here

public static final int SUCCESS = 1;

4. The uri to UriMatcher, patients

static
{
        UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        uriMatcher.addURI(MY_URI, null, SUCCESS);
}

5. AndroidManifest.xml configure ContentProvider

<provider android:name="com.test.provider.DataContentProvider"
        android:authorities="com.test.dataContentProvider" />

com.test.provider.DataContentProvider is your custom ContentProvider path, including the package name and class name

com.test.dataContentProvider is that you value defined above MY_URI

Use:

1. ContentProvider to use the definition of the URI string, note: and when writing ContentProvider different, then the definition of the address URI is the complete URI

private static final String MY_URI = "content://com.test.dataContentProvider";

2. Been the object URI

Uri uri = Uri.parse(MY_URI);

3. Get Cursor

Cursor cursor =  getContentResolver().query(uri, null, null, null, null);
相关文章
  • Steps to prepare and use ContentProvicer 2011-05-26

    Write: 1. Write a class, inheritance android.content.ContentProvider 2. Define a uri string, for example: private static final String MY_URI = "com.test.dataContentProvider"; 3. You can define a path corresponding to the code, when the match is

  • Steps to prepare aidl android 2011-05-24

    A 1. Preparation aidl file 2. Write your own Service 3. In their own Service's onBind method, the aidl file generated class a subclass of return Stud (Stud override the interface method needs to inherit) 4. AndroidManifest.xml configured in your Serv

  • Operations in the management summary of the software testing 2010-02-24

    × × × × × I project is the company's first software testing project is the first direct operations in the management of software testing. Previously, the organization and management outsourcing, testing and implementation of personnel conducted softw

  • JUnit Cookbook (translation) 2010-08-07

    Study: Kent Beck, Eric Gamma This is a guide you follow the steps to prepare and organize the use JUnit unit test your own manual. How do you write a simple test case test code? The easiest way is as an expression in the debugger. You do not need to

  • Servlet activation device and the default Servlet [change] 2010-08-20

    Servlet Activator: In tomcat5.x version tomcat installation directory of the conf directory in the web.xml file such a comment: <! - <servlet> <servlet-name> invoker </ servlet-name> <servlet-class> org.apache.catalina.servlets.

  • Flex in the itemRenderer to use (2) external renderer 2010-08-21

    The first of this series Part 1, the I showed you how to create within the Lian itemRenderer-Zhe Zhong itemRenderer in MXML and ActionScript Dai Ma Biao Ji Shi Yong Gai itemRenderer with the list in the same file. Code and file the rest of the code i

  • scala's an example of the deployment liftweb 2010-10-26

    These days, has been looking at aspects of information scala, feel the simplicity of functional programming, sometimes also think, Kent Beck is also the language from the functional expression of the function to draw simple type of thinking? Ha ha. A

  • Flex external renderer (on) 2010-12-07

    You should also remember that I said, the inline itemRenderer should be treated as a separate category. In fact, Flex compiler extract the inline code and create your class. The advantages of the inline itemRenderer code list in the same location, bu

  • Use native SQL query JPQL and JPA entities (rpm) 2010-12-30

    Of: Yuli Vasiliev Learn how to use the Java Persistence query language and native SQL query JPA entities. Published September 2008 In the Java EE, Java Persistence API (JPA) is a standard for accessing relational database API, which provides a simple

  • [Transfer] Flex itemRenderer used in (b) of the external renderer 2010-12-31

    http://nianshi.javaeye.com/blog/743826 In Part 1 of this series, I show you how to create an inline itemRenderer-that the MXML tags and ActionScript itemRenderer code list and use the itemRenderer in the same file. The rest of the code and file code

  • Call WebService using KSOAP2 2011-05-24

    Go to this article: http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=2352 Installing third-party libraries: KSOAP2 PC version of the WebService client library is very rich, for example, Axis2, CXF, etc., but these libraries for th

  • Summary of software testing templates 2009-08-12

    The following summary of some of the software commonly used to test the template. A software test plan template (short type) A description of the test tasks the composition of the system described here, including what the needs of each subsystem subs

  • Ubuntu 10.04 to modify the MySQL datadir issue 2011-10-23

    Ubuntu 10.04 to modify the MySQL datadir issue 2011-09-08 14:21:59 Add a comment 0 I want to submission [font: big or small] As the report server space tight, you will need the mysql datadir under Ubuntu 10.04 from the default of / var / lib / mysql

  • Steps and methods of research needs 2009-07-02

    Steps and methods of research needs Chapter 1 Introduction Purpose Research needs statement for the needs of the preliminary work, it can be said that the demand specification sheet from the research needs to be or taken out. Demand for research is t

  • [Change] IBM DB2 cross-platform database migration steps and precautions 2010-03-29

    This article introduces the IBM DB2 database cross-platform migration of specific steps and precautions, for more information see below. db2 is a wide range of business applications with relational database software. As a database administrator is of

  • SSH with MyEclipse8.5 development environment and build the steps to access the database (with project files and screenshots) 2010-04-29

    SSH configuration steps Tool MyEclipse8.5 asm3.2.jar Log4j.proerties Target <br /> configure a SSH-based development environment to do a simple database CRUD examples Steps to set up the environment <br /> 00 to prepare the database and table

  • Steps To Migrate / Move a Database From Non-ASM to ASM And Vice-Versa [ID 252219.1 2010-05-14

    Applies to: Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 11.1.0.7 Information in this document applies to any platform. Purpose This article describes the steps to migrate a database from Non-ASM to ASM and vice-versa. To setup ASM, plea

  • Apache Tomcat 5.5 Servlet / JSP container how to prepare Cluster / Session Replication 2010-06-18

    Source text: http://www.jaxmao.org/tomcat-docs/cluster-howto.html Apache Tomcat 5.5 Servlet / JSP container How to prepare the cluster / Session Replication Getting Started To the Tomcat 5.5 container for session replication, you must complete the fo

  • Graphical SSH framework configuration steps 2010-08-05

    Now developed a project using S2SH framework, configuration environment with a day or two, and now the environment was configured to write to the document issued under the order, are also considered to enhance point memory. A development environment

  • The main steps Of the use Of Your Business 2010-11-20

    Furthermore, it is possible to double the tax can be removed by the election of the Corporation by the internal RevenueService. ∪ capital may be increased to facilitate the sale of ofstock. The Corporation has the feature of unlimited period. Most co