Skip to content

Commit

Permalink
1.7 Add ContentProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Beginning Android committed Aug 23, 2016
1 parent d9d1e99 commit 7d0e356
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".CatalogActivity" />
</activity>
<provider
android:name=".data.PetProvider"
android:authorities="com.example.android.pets"
android:exported="false" />
</application>

</manifest>
61 changes: 61 additions & 0 deletions app/src/main/java/com/example/android/pets/data/PetProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.pets.data;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

/**
* {@link ContentProvider} for Pets app.
*/
public class PetProvider extends ContentProvider {

/** Database helper object */
private PetDbHelper mDbHelper;

@Override
public boolean onCreate() {
mDbHelper = new PetDbHelper(getContext());
return true;
}

@Override
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
return null;
}

@Override
public String getType(Uri uri) {
return null;
}

@Override
public Uri insert(Uri uri, ContentValues contentValues) {
return null;
}

@Override
public int delete(Uri uri, String s, String[] strings) {
return 0;
}

@Override
public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
return 0;
}
}

6 comments on commit 7d0e356

@moreghz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the quiz that linked to this gist stated that there would be a TODO item in this code?

@jtryan
Copy link

@jtryan jtryan commented on 7d0e356 Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Review of course content πŸ‘Ž

@noahhkim
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the TODO item was already done for us

@bamakant
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its really helps me to save time and learn the concept easily and quickly.

@Babadzhanov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!!

@Bong79
Copy link

@Bong79 Bong79 commented on 7d0e356 Sep 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ride on

Please sign in to comment.