Java ContentProvider.createUri无法解析方法?

Java ContentProvider.createUri无法解析方法?,java,android,cursor,uri,adapter,Java,Android,Cursor,Uri,Adapter,我不知道为什么我不能编译我的代码,它设置我ContentProvider.createUri无法解析方法。谁能告诉我我错过了什么。这是我的课程代码: public class Connectivity extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> { MySQLiteHelper db; String[] name; String[] usernam

我不知道为什么我不能编译我的代码,它设置我ContentProvider.createUri无法解析方法。谁能告诉我我错过了什么。这是我的课程代码:

public class Connectivity extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {

        MySQLiteHelper db;
        String[] name;
        String[] username;
        String[] password;
        String[] category;
        int[] ids;
        int[] color;
        ListView listView;

        Cursor identityCursor;

        FloatingActionButton addIndentity;
        int REQUEST_CODE =0;

        int color1;

        ToastersAdapter customAdapter;

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View android = inflater.inflate(R.layout.cards_frag, container, false);

            addIndentity = (FloatingActionButton) android.findViewById(R.id.fab3);

            db = new MySQLiteHelper(getActivity());


                  final List<IdentityHelper> list = db.getAllIdentities();


            name= new String[db.getIdentitiesCount()];
            username = new String[db.getIdentitiesCount()];
            password = new String[db.getIdentitiesCount()];
            category = new String[db.getIdentitiesCount()];
            color = new int[db.getIdentitiesCount()];
            ids = new int[db.getIdentitiesCount()];

            for (int i = 0; i < list.size(); i++) {
                IdentityHelper n= list.get(i);
                name[i]= n.getName();
                username[i]=n.getUsername();
                password[i]=n.getPassword();
                category[i]=n.getCategory();
                color[i] = n.getColor();
                ids[i] = n.getId();

            }

            addIndentity.setOnClickListener(handler);



            // Get access to the underlying writeable database
            SQLiteDatabase dbs = db.getWritableDatabase();
    // Query for items from the database and get a cursor back
            identityCursor = dbs.rawQuery("SELECT  * FROM Identities ORDER BY category", null);


            listView = (ListView) android.findViewById(R.id.listView1);


              customAdapter = new ToastersAdapter(getActivity(), identityCursor);
            listView.setAdapter(customAdapter);
            addIndentity.attachToListView(listView);
            getActivity().getSupportLoaderManager().initLoader(0, null, Connectivity.this);




            listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
            {
                @Override
                public void onItemClick(AdapterView<?> adapter, View v, int position,
                                        long arg3)
                {



                    ToastersAdapter adapter1 = (ToastersAdapter) adapter.getAdapter();
                    Object sectionObject = adapter1.getItem(position);
                    int cursorPosition = adapter1.getCursorPositionWithoutSections(position);

                    if (adapter1.isSection(position) && sectionObject != null) {
                        // Handle the section being clicked on.
                        Toast.makeText(getActivity(),"Header Clicked", Toast.LENGTH_SHORT).show();
                    } else if (cursorPosition != SectionCursorAdapter.NO_CURSOR_POSITION) {
                        // Handle the cursor item being clicked on.


                                        //Create the bundle
                    Bundle bundle = new Bundle();
                    //Add your data from getFactualResults method to bundle
                    bundle.putString("Name", name[cursorPosition]);
                    bundle.putString("Username",username[cursorPosition]);
                    bundle.putString("Password",password[cursorPosition]);
                    bundle.putString("Category", category[cursorPosition]);
                    bundle.putInt("Color", color[cursorPosition]);
                    bundle.putInt("ID", ids[cursorPosition]);



                    Intent intent = new Intent(getActivity(), theIdentity.class);
                    intent.putExtras(bundle);
                    Connectivity.this.startActivity(intent);
                    getActivity().overridePendingTransition(R.anim.slide_in_top, R.anim.slide_out_top);
                    getActivity().finish();

                }}
            });



            return android;
        }


        @Override
        public Loader<Cursor> onCreateLoader(int id, Bundle args) {


           **String orderBy = category[id] + " ASC, " + name[id] + " ASC";
            return new CursorLoader(this, ContentProvider.createUri(IdentityHelper.class, null), null, null, null, orderBy);**

        }

        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

            customAdapter.swapCursor(data);

        }

        @Override
        public void onLoaderReset(Loader<Cursor> loader) {

            customAdapter.swapCursor(null);
        }
公共类连接扩展片段实现LoaderManager.LoaderCallbacks{
MySQLiteHelper数据库;
字符串[]名称;
字符串[]用户名;
字符串[]密码;
字符串[]类别;
int[]id;
int[]颜色;
列表视图列表视图;
游标标识游标;
浮动操作按钮附加值;
int请求_代码=0;
int-color1;
烤面包机适配器;
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
查看android=充气机。充气(R.layout.cards\u frag,container,false);
addendentity=(FloatingActionButton)android.findViewById(R.id.fab3);
db=新的MySQLiteHelper(getActivity());
最终列表列表=db.getAllIdentities();
name=新字符串[db.getIdentitiesCount()];
用户名=新字符串[db.getIdentitiesCount()];
password=新字符串[db.getidentiescount()];
category=新字符串[db.getIdentitiesCount()];
color=newint[db.getidentiescount()];
ids=new int[db.getIdentitiesCount()];
对于(int i=0;i
我已经使用,作为游标适配器来操作ListView。我将非常感谢您的帮助

我不知道为什么我不能编译我的代码,它设置我ContentProvider.createUri无法解析方法


没有名为
createUri()
的方法,无论是静态的还是其他的。

由于类中没有
createUri
方法,我觉得您的
ContentProvider
类来自其他库。
可能是这样,它在
com.activeandroid.content.ContentProvider
类中有
createUri
方法。

不,我没有用它,实际上我用的是@MussaI。我已经查找了部分CursorAdapter库,发现他的作者正在使用activeandroid。@JanaLook查看这个类中的导入