I want to get data from launcher db.
final String AUTHORITY = "com.android.launcher2.settings";  
final Uri CONTENT_URI = Uri.parse("content://" + 
                        AUTHORITY + "/favorites?notify=true");
Cursor c = contentResolver.query(uri, columns, null, null,
            null);
and
<uses-permission 
        android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission 
        android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
<uses-permission 
        android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission 
        android:name="com.android.launcher.permission.WRITE_SETTINGS" />
but it's said that in logcat:
Failed to find provider info for com.android.launcher2.settings
                The launcher is an Application under the Handset Manufacturer responsibility.
The Authority is then not always "com.android.launcher2.settings".
The Handset Manufacturer may rewrite its own.
It can be "com.android.twlauncher" or anything else depending on the Java package.
You need to retrieve the right authority by searching for a provider that declares the read/write permissions "com.android.launcher.permission.READ_SETTINGS" or "com.android.launcher.permission.WRITE_SETTINGS".
This is a sample code to do that:
static String getAuthorityFromPermission(Context context, String permission){
    if (permission == null) return null;
    List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS);
    if (packs != null) {
        for (PackageInfo pack : packs) { 
            ProviderInfo[] providers = pack.providers; 
            if (providers != null) { 
                for (ProviderInfo provider : providers) { 
                    if (permission.equals(provider.readPermission)) return provider.authority;
                    if (permission.equals(provider.writePermission)) return provider.authority;
                } 
            }
        }
    }
    return null;
}
Generally, the ContentProvider and DB structure is kept, and you can use the same queries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With