(8) Launcher3 customized ContentProvider content providers, implementing other applications to modify database updates and other operations

Source: Internet
Author: User

Add two permissions First

<uses-permission android:name= "Com.android.launcher3.permission.READ_SETTINGS"/>
<uses-permission android:name= "Com.android.launcher3.permission.WRITE_SETTINGS"/>

These two are permissions to modify the desktop's database

You can't change it without adding it!

Get data directly from content providers,

Static arraylist<shortcutinfo> Getitemsinlocalcoordinates (context context) {arraylist<shortcutinfo> it        EMS = new arraylist<shortcutinfo> ();        Final Contentresolver cr = Context.getcontentresolver (); Cursor C = cr.query (LauncherSettings.Favorites.CONTENT_URI, new string[] {LauncherSettings.Favorites.ITEM_ TYPE, LauncherSettings.Favorites.CONTAINER, LauncherSettings.Favorites.SCREEN, LAUNCHERSETTINGS.FAVORITES.C ELLX, LauncherSettings.Favorites.CELLY, LauncherSettings.Favorites.SPANX, LauncherSettings.Favorites.SPANY        , launchersettings.favorites.title,launchersettings.favorites.intent}, NULL, NULL, NULL);        Final int itemtypeindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.ITEM_TYPE);        Final int containerindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.CONTAINER);        Final int screenindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.SCREEN); Final int Cellxindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.CELLX);        Final int cellyindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.CELLY);        Final int spanxindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.SPANX);        Final int spanyindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.SPANY);        Final int titleindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.TITLE);        Final int intenindex = C.getcolumnindexorthrow (LauncherSettings.Favorites.INTENT);                try {while (C.movetonext ()) {Shortcutinfo item = new Shortcutinfo ();                ITEM.CELLX = C.getint (Cellxindex);                item.celly = C.getint (Cellyindex);                Item.spanx = Math.max (1, C.getint (Spanxindex));                Item.spany = Math.max (1, C.getint (Spanyindex));                Item.container = C.getint (Containerindex);                Item.itemtype = C.getint (Itemtypeindex); Item.screenid = C.getint (Screenindex);                Item.title=c.getstring (Titleindex);                if (c.getstring (intenindex)!=null) {item.intent=new Intent (c.getstring (Intenindex));            } items.add (item);        }} catch (Exception e) {items.clear ();        } finally {c.close ();    } return items; }
Modify the content similarly by the URL to modify,

I will not write the code specifically.

(8) Launcher3 customized ContentProvider content providers, implementing other applications to modify database updates and other operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.