shared_preferences_content_provider 0.0.2 copy "shared_preferences_content_provider: ^0.0.2" to clipboard
shared_preferences_content_provider: ^0.0.2 copied to clipboard

A Flutter package support share data between multiple application via content provider.

shared_preferences_content_provider #

pub package

Shared preference supporting Android content provider

Note: Only support Android

Usage #

To use this plugin, add shared_preferences_content_provider as a dependency in your pubspec.yaml file.

Example #

Add this to AndroidManifest.xml

Host app (Provider app):
<manifest>
    <application>
         <provider
           android:name="com.zhgwu.shared_preferences_content_provider.SharedPreferencesContentProvider"
           android:authorities="com.zhgwu.shared_preferences_content_provider.example"
           android:readPermission="shared_preferences.permission.READ_TOKEN"
           android:writePermission="shared_preferences.permission.WRITE_DATA"
           android:enabled="true"
           android:exported="true" />
    </application>

   
</manifest>
Consumer app:
<manifest>
    <queries>
        <package android:name="com.zhgwu.shared_preferences_content_provider_example" />  <!--host app package-->
    </queries>
    <uses-permission android:name="shared_preference.permission.WRITE_DATA" />
    <uses-permission android:name="shared_preference.permission.READ_DATA" />
</manifest>
// The content provider must be set up first
await SharedPreferencesContentProvider.init(
    providerAuthority:
    'com.zhgwu.shared_preferences_content_provider.example',  //authority provider in AndroidManifest.xml
);
// Put values
await SharedPreferencesContentProvider.putBool('MY_BOOL_KEY', true);
await SharedPreferencesContentProvider.putString('MY_STRING_KEY', 'STRING_VALUE');
await SharedPreferencesContentProvider.putInt('MY_INT_KEY', 42);
await SharedPreferencesContentProvider.putDouble('MY_DOUBLE_KEY', 9.9);
// Get values
bool boolValue = await SharedPreferencesContentProvider.get('MY_BOOL_KEY');
String stringValue = await SharedPreferencesContentProvider.get('MY_STRING_KEY');
int intValue = await SharedPreferencesContentProvider.get('MY_INT_KEY');
double doubleValue = await SharedPreferencesContentProvider.get('MY_DOUBLE_KEY');
3
likes
0
points
137
downloads

Publisher

verified publishermag1c.dev

Weekly Downloads

A Flutter package support share data between multiple application via content provider.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on shared_preferences_content_provider