|
| 1 | +package com.amitshekhar.debug.encrypt; |
| 2 | + |
| 3 | +import android.content.ContentProvider; |
| 4 | +import android.content.ContentValues; |
| 5 | +import android.content.Context; |
| 6 | +import android.content.pm.ProviderInfo; |
| 7 | +import android.database.Cursor; |
| 8 | +import android.net.Uri; |
| 9 | + |
| 10 | +import com.amitshekhar.DebugDB; |
| 11 | + |
| 12 | +public class DebugDBEncryptInitProvider extends ContentProvider { |
| 13 | + |
| 14 | + |
| 15 | + public DebugDBEncryptInitProvider() { |
| 16 | + } |
| 17 | + |
| 18 | + @Override |
| 19 | + public boolean onCreate() { |
| 20 | + DebugDB.initialize(getContext()); |
| 21 | + return true; |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { |
| 26 | + return null; |
| 27 | + } |
| 28 | + |
| 29 | + @Override |
| 30 | + public String getType(Uri uri) { |
| 31 | + return null; |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public Uri insert(Uri uri, ContentValues values) { |
| 36 | + return null; |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public int delete(Uri uri, String selection, String[] selectionArgs) { |
| 41 | + return 0; |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { |
| 46 | + return 0; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public void attachInfo(Context context, ProviderInfo providerInfo) { |
| 51 | + if (providerInfo == null) { |
| 52 | + throw new NullPointerException("DebugDBEncryptInitProvider ProviderInfo cannot be null."); |
| 53 | + } |
| 54 | + // So if the authorities equal the library internal ones, the developer forgot to set his applicationId |
| 55 | + if ("com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider".equals(providerInfo.authority)) { |
| 56 | + throw new IllegalStateException("Incorrect provider authority in manifest. Most likely due to a " |
| 57 | + + "missing applicationId variable in application\'s build.gradle."); |
| 58 | + } |
| 59 | + super.attachInfo(context, providerInfo); |
| 60 | + } |
| 61 | + |
| 62 | +} |
0 commit comments