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