Jana
Jana

Reputation: 68

ContentProvider.createUri Cannot resolve method?

I dont know why i cant compile my code , it is setting me that ContentProvider.createUri cannot resolve method. What i am missing can anyone tell me please. Here is my code for class:

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);
        }

I have used https://github.com/twotoasters/SectionCursorAdapter, for Cursor adapter to manipulate the ListView. I will really appreciate any help

Upvotes: 0

Views: 427

Answers (2)

Mussa
Mussa

Reputation: 1499

Since there is no createUri method in android.content.ContentProvider class, it appears to me that your ContentProvider class is from some other library. May be it is ActiveAndroid, which has createUri method in com.activeandroid.content.ContentProvider class.

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1006604

I dont know why i cant compile my code , it is setting me that ContentProvider.createUri cannot resolve method

There is no method named createUri() on ContentProvider, whether static or otherwise.

Upvotes: 0

Related Questions