Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:55:03+00:00 2026-05-26T16:55:03+00:00

=== about me === I’m new to android development and barely able to speak

  • 0

=== about me ===

I’m new to android development and barely able to “speak” Java. Nevertheless I’m experienced in PHP5 and C++ C++/CLI (.net >2.0) so I hope I’ll be able to create this little app, that is in my mind.

But after a few days of experimenting I’m in a kind of pitfall now, and hope you can help me.

=== about the project ===

I’ve got an listview (nested within other layout) and try to populate it with data from a sqlite. I managed to get the thing up and running with a simple “arrayAdapter”, but researching how I could update it if I insert new elemnts in the database with a popup I figured out that I need to implement my own content provider.

=== about the problem ===

I browsed a few tutorials and did so, but now I have problems calling it because of the URI. I don’t understand how it should be created and so I can’t create a valid one.

Here is the problem in code:

TBTTManageBudgetsActivity.java

package com.TBTT;

// ...
// some imports
// ...

public class TBTTManageBudgetsActivity extends Activity {
    // ...
    // some declarations
    // ...

    @Override
    public void onCreate(Bundle savedInstanceState) {
        // Initialisation
            super .onCreate(savedInstanceState);
            setContentView(R.layout.manage_budgets);

        // ...
        // some stuff concerning other elements
        // ...

    // Fill List View
        // Get the list view
            ListView listView = (ListView) findViewById(R.id.list_box);     
            // Get content provider and cursor
                String[] projection = { TBTCPHBudget.KEY_ROWID, TBTCPHBudget.KEY_NAME };
                String[] uiBindFrom = { TBTCPHBudget.KEY_ROWID};
                int[] uiBindTo = { R.id.name };             
                TBTCPBdugets ContentProvider = new TBTCPBdugets();        
                Cursor cursor = ContentProvider.query(TBTCPBdugets.CONTENT_URI, projection,null, null, null);               
            // Let activity manage the cursor
                startManagingCursor(cursor);
            // Get value from content provider
                cursor.moveToFirst();
                ArrayList list = new ArrayList<String>();
                do {
                    list.add(cursor.getString(1));
                } while (cursor.moveToNext());
            // Set Values with Adapter
                CursorAdapter adapter = new SimpleCursorAdapter(this.getApplicationContext(), R.layout.list_budgets_item, cursor, uiBindFrom, uiBindTo);
                listView.setAdapter(adapter);               
    }

    // ...
    // some other functions
    // ...
}

TBTCPBdugets.java

package com.TBTT;
// ...
// some imports
// ...

public class TBTCPBdugets extends ContentProvider {
    // ...
    // some declarations
    // ...
    public static final String AUTHORITY = "com.TBTT";
    public static final String DATAPATH = "TBTCPHBudget";
    public static final Uri CONTENT_URI = Uri.parse("content://"+ AUTHORITY+"/" + DATAPATH);
    private static final UriMatcher sUriMatcher;

    private static class DatabaseHelper extends SQLiteOpenHelper {
        // ...
        // some other functions
        // ...
    }

    private DatabaseHelper dbHelper;

    // ...
    // some other functions
    // ...

    @Override
    public boolean onCreate() {
        dbHelper = new DatabaseHelper(getContext());
        return true;
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        switch (sUriMatcher.match(uri)) {        
            case BUDGETS:               
                qb.setTables(BUDGETS_TABLE_NAME);            
                qb.setProjectionMap(notesProjectionMap);
                break;
        default:            
            Log.d(TAG, "Unknown URI " + uri+" with URIMatcher Result "+sUriMatcher.match(uri));             
            throw new IllegalArgumentException("Unknown URI " + uri);
        }

        SQLiteDatabase db = dbHelper.getReadableDatabase();
        Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);

        c.setNotificationUri(getContext().getContentResolver(), uri);
        return c;
    }

    static {
        sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        sUriMatcher.addURI(AUTHORITY, BUDGETS_TABLE_NAME, BUDGETS);

        // ...
        // some declarations
        // ...
    }
}

When I run this and open the TBTTManageBudgetsActivity the program will crash. The debug output from the TBTCPBdugets.java says: “Unknown URI content://com.TBTT/TBTCPBdugets with URIMatcher Result -1”.

Can anybody tell me please how to create a VALID URI for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:55:04+00:00Added an answer on May 26, 2026 at 4:55 pm

    Your UriMatcher don’t know about your CONTENT_URI. There are DATAPATH in CONTENT_URI, but BUDGETS_TABLE_NAME in matcher.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

About a week ago I was able to scan images using my 64bit .net
about a year ago I stumbled across a nice feature in Java that I
About to start a new project in VS2010 which will have a few windows
//About Button in the principal menu final Button button3 = (Button) findViewById(R.id.button3); button3.setOnClickListener( new
Thinking about getting into .net technology project management I've had plenty of experience with
about static function in c++,what is corresponding feature in Java Thank you
about nested dom bindings http://jsfiddle.net/sxd1140/XWvYk/1/ is only this way https://github.com/hunterloftis/knockout.namespaces or have other way
About a year ago I started to built an application for android. Now when
About 6 months ago I rolled out a site where every request needed to
About a year ago, I picked up Scott Ambler's Refactoring Databases: Evolutionary Database Design

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.