-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. SelectContacts Completed 3. Fetch Contacts via Custom Content Provider Completed.
- Loading branch information
1 parent
b6f4741
commit c7cb06e
Showing
5 changed files
with
166 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/BugBazaar/provider/MyContactsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.BugBazaar.provider; | ||
import android.content.ContentProvider; | ||
import android.content.ContentResolver; | ||
import android.content.ContentValues; | ||
import android.content.UriMatcher; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.provider.ContactsContract; | ||
|
||
public class MyContactsProvider extends ContentProvider { | ||
// Define your authority and content URI | ||
public static final String AUTHORITY = "com.bugbazaar.mycontacts"; | ||
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/contacts"); | ||
|
||
@Override | ||
public boolean onCreate() { | ||
// Initialize your database or data source here | ||
// Return true if initialization is successful | ||
return true; | ||
} | ||
|
||
@Override | ||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { | ||
|
||
// Query the ContactsContract to retrieve all contacts | ||
return getContext().getContentResolver().query( | ||
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, | ||
projection, | ||
selection, | ||
selectionArgs, | ||
sortOrder | ||
); | ||
} | ||
|
||
@Override | ||
public Uri insert(Uri uri, ContentValues values) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { | ||
// Implement update operation if needed | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int delete(Uri uri, String selection, String[] selectionArgs) { | ||
// Implement delete operation if needed | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String getType(Uri uri) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#667D97" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters