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 6888003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:57:18+00:00 2026-05-27T05:57:18+00:00

This is my first time using a content provider but I followed the developer

  • 0

This is my first time using a content provider but I followed the developer docs but when I run the program it tells me failed to find provider info

here is my manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tyczj.bowling"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="11" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <activity android:name="Tabs">
        <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
    </activity>

    <activity android:name="BowlersList"></activity>
</application>

<provider android:name="com.tyczj.bowling.BowlersDB"
    android:authorities="com.tyczj.bowling.bowlersdb">
</provider>

</manifest>

and my content provider

public class BowlersDB extends ContentProvider {

private static final String DATABASE_NAME = "Bowlers";
private static final String BOWLERS_TABLE = "bowlers_table";
private static final int DATABASE_VERSION = 1;
public static final Uri CONTENT_URI = Uri.parse("content://com.tyczj.bowling.bowlersdb");
private static final UriMatcher uriMatcher;
static final String NAME = "name";
static final String ID = "_id";

private DatabaseHelper DBHelper;
private SQLiteDatabase db;

public Cursor getBowlers(){
    return db.query(BOWLERS_TABLE, new String[] {ID,NAME},null,null,null,null,NAME + " ASC");
}

public Cursor getId(String name){
    Cursor c = db.query(BOWLERS_TABLE, new String[] {ID,NAME},NAME + "='" + name +"'",null,null,null,null);
    if(c != null && c.moveToFirst()){
        do{
            if(c.getString(c.getColumnIndex(NAME)).equals(name)){
                return c;
            }
        }while(c.moveToNext());
    }
    return c;
}

private static class DatabaseHelper extends SQLiteOpenHelper 
{
    DatabaseHelper(Context context) 
    {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) 
    {
        createTables(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, 
                          int newVersion) 
    {
        Log.w("CalendarDB", "Upgrading database from version " + oldVersion 
              + " to "
              + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS Events_Table");
        onCreate(db);
    }

    private void createTables(SQLiteDatabase db){
        db.execSQL("CREATE TABLE " + BOWLERS_TABLE + "(" + ID + " integer primary key autoincrement, " +
                NAME + " TEXT);");
    }
}

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    int count = 0;
    int num = uriMatcher.match(uri);
    if(num == 1){
        count = db.delete(BOWLERS_TABLE, selection,selectionArgs);
    }else if(num == 2){
        String id = uri.getPathSegments().get(1);
        count = db.delete(BOWLERS_TABLE, ID + " = " + id + (!TextUtils.isEmpty(selection) ? " AND (" + 
                   selection + ')' : ""), 
                   selectionArgs);
    }
    getContext().getContentResolver().notifyChange(uri, null);
    return count;
}

@Override
public String getType(Uri uri) {
    if(uriMatcher.match(uri) == 1){
        return "vnd.android.cursor.dir/vnd.tyczj.bowlersdb ";
    }else if(uriMatcher.match(uri) == 2){
        return "vdn.android.cursor.item/vnd.tyczj.bowlersdb ";
    }else
        throw new IllegalArgumentException("Unsupported URI: " + uri);

}

@Override
public Uri insert(Uri uri, ContentValues values) {
    long rowID = db.insert(BOWLERS_TABLE,null, values);
    if(rowID > 0){
        Uri _uri = ContentUris.withAppendedId(CONTENT_URI,rowID);
        getContext().getContentResolver().notifyChange(_uri,null);
        return _uri;
    }else{
        throw new SQLException("Failed to insert row into " + uri);
    }
}

@Override
public boolean onCreate() {
    Context context = getContext();
    DBHelper = new DatabaseHelper(context);
    db = DBHelper.getWritableDatabase();
    return (db == null)? false:true;
}

@Override
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
    sqlBuilder.setTables(BOWLERS_TABLE);

    if(uriMatcher.match(uri) == 1){
        sqlBuilder.appendWhere(ID + " = " + uri.getPathSegments().get(1));
    }
    if(sortOrder == null || sortOrder == "")
        sortOrder = NAME;
    Cursor c = sqlBuilder.query(db, projection, selection, selectionArgs,null,null, sortOrder);
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}

@Override
public int update(Uri uri, ContentValues values, String selection,
        String[] selectionArgs) {
    int count = 0;
    int num = uriMatcher.match(uri);
    if(num == 1){
        count = db.update(BOWLERS_TABLE, values, selection, selectionArgs);
    }else if(num == 2){
        count = db.update(BOWLERS_TABLE, values, ID + " = " + uri.getPathSegments().get(1) + (!TextUtils.isEmpty(selection) ? " AND (" + 
                  selection + ')' : ""), 
                  selectionArgs);
    }else{
        throw new IllegalArgumentException(
                "Unknown URI " + uri);
    }
    getContext().getContentResolver().notifyChange(uri, null);
    return count;
}

static{
    uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    uriMatcher.addURI("com.tyczj.bowling.bowlersdb","bowlers",1);
    uriMatcher.addURI("com.tyczj.bowling.bowlersdb","bowlers/#",2);
}

}

not sure what I did wrong?

  • 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-27T05:57:19+00:00Added an answer on May 27, 2026 at 5:57 am

    Provider needs to be in the application tag.

        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.tyczj.bowling"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk android:minSdkVersion="11" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
    
            <activity android:name="Tabs">
                <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
            </activity>
    
            <activity android:name="BowlersList"></activity>
        <provider android:name="com.tyczj.bowling.BowlersDB"
            android:authorities="com.tyczj.bowling.bowlersdb">
        </provider>
        </application>
    
    
    
    </manifest>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this XML classes for the first time and can't find this piece
This is my first time using joomla. I don't know if I'm using the
this is my first time using StAX for parsing XML documents (still in the
I'm fairly new to both Django and Python. This is my first time using
This is the first time ever I'm using AJAX, and I want to do
I'm using this line to get the beginning time of the first day of
First time using this service for a question. I hope I am not asking
I am using HTML 5 for the first time, and playing around with this
This is my first time using Stack Overflow, so if I've done something wrong
this is my first time really using this site. I'm relatively new to using

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.