launcher 桌面启动器的DB文件数据处理操作
2013-01-28 13:56
260 查看
launcher-----启动器中的launcher.db文件的数据处理方法:
主要是查询,更新数据:
主要是查询,更新数据:
/** * 类描述:缩略图帮助类 * @author hexiaoming * @version */ public class PreviewHelper { /********WorkspaceScreen的最大值*******/ public static final int MaxWorkspaceScreen = 40; private Context context = null; public static final String Preview_Helper = "Preview_Helper"; public static final String AUTHORITY = "com.konka.launcher2.settings"; public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + "favorites" + "?" + "notify" + "=true"); //Uri.parse("content://" + AUTHORITY + "favorites"); private static String[] projection = new String[] {"container","screen"}; private static String[] projection_delete = new String[] {"_id","container","screen"}; public static final int CONTAINER_DESKTOP = -100; /** * 方法描述:PreviewHelper的构造方法 * @param * @return * @see PreviewHelper */ public PreviewHelper(Context context) { this.context = context; } /** * 方法描述:getArrayListForScreenIsNull方法,获取表示当前界面是否没有APP和Weight的ArrayList * @param * @return ArrayList<Boolean> * @see PreviewHelper */ public Boolean[] getScreenIsNull() { int length = LauncherPreviewActivity.bitmaps.size(); Boolean[] screenIsNull = new Boolean[length] ; for(int i=0;i<screenIsNull.length;i++) { screenIsNull[i] = true; } final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( CONTENT_URI, projection, null, null, null); final int containerIndex = c.getColumnIndexOrThrow(projection[0]); final int screenIndex = c.getColumnIndexOrThrow(projection[1]); int container; int screen; try { while (c.moveToNext()) { container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { screenIsNull[screen] = false; } } } catch (Exception e) { } finally { c.close(); } return screenIsNull; } /** * 方法描述:ProcessDBForDeletePreviewScreen方法,处理删除缩略图片item_delete时的launcher.db数据 * @param int item_delete * @return void * @see PreviewHelper */ public void ProcessDBForDeletePreviewScreen(int item_delete) { final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( CONTENT_URI, projection_delete, null, null, null); final int favoriteIdIndex = c.getColumnIndexOrThrow(projection_delete[0]); final int containerIndex = c.getColumnIndexOrThrow(projection_delete[1]); final int screenIndex = c.getColumnIndexOrThrow(projection_delete[2]); int favoritedId; int container; int screen; ContentValues values = new ContentValues(); try { while (c.moveToNext()) { favoritedId = c.getInt(favoriteIdIndex); container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { if(screen > item_delete) { values.clear(); values.put("SCREEN", screen - 1); String updateWhere = "_id" + "=" + favoritedId; // String updateWhere = "(" + "SCREEN" + " == 'screen' " + ")" + "AND" // + "(" + "container" + "== 'container'" + ")" ; // BluetoothShare.STATUS + " >= '200' AND " + "(" + BluetoothShare.VISIBILITY + " IS NULL OR " // + BluetoothShare.VISIBILITY + " == '" + BluetoothShare.VISIBILITY_VISIBLE + "'" + ")"; cr.update( CONTENT_URI, values, updateWhere, null);} } } } catch (Exception e) { } finally { c.close(); } } /** * 方法描述:ProcessDBForExchangePreviewScreen方法,处理拖动缩略图片时的launcher.db数据 * @param int start_item,int end_item * @return void * @see PreviewHelper */ public void ProcessDBForExchangePreviewScreen(int start_item,int end_item) { final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( CONTENT_URI, projection_delete, null, null, null); final int favoriteIdIndex = c.getColumnIndexOrThrow(projection_delete[0]); final int containerIndex = c.getColumnIndexOrThrow(projection_delete[1]); final int screenIndex = c.getColumnIndexOrThrow(projection_delete[2]); int favoritedId; int container; int screen; ContentValues values = new ContentValues(); if(start_item < end_item) { try { while (c.moveToNext()) { favoritedId = c.getInt(favoriteIdIndex); container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { if(screen == start_item) { values.clear(); values.put("SCREEN", end_item); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } if(screen > start_item && screen <= end_item) { values.clear(); values.put("SCREEN", screen - 1); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } } } } catch (Exception e) { } finally { c.close(); } } if(start_item > end_item) { try { while (c.moveToNext()) { favoritedId = c.getInt(favoriteIdIndex); container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { if(screen == start_item) { values.clear(); values.put("SCREEN", end_item); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } if(screen >= end_item && screen < start_item) { values.clear(); values.put("SCREEN", screen + 1); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } } } } catch (Exception e) { } finally { c.close(); } } } }
相关文章推荐
- 使用C# 怎么生成.db后缀的文件,并且能够使用sql语言进行读取等 操作
- Linux 桌面启动器 文件实例
- [原]用c#做了一个桌面程序用来分离excel文件里的数据时出现“操作必须使用一个可更新的查询”错误的解决
- Android 如果读取asserts 中的db文件,并进行查询操作
- 安卓系统中的桌面启动器Launcher
- 树莓派 Learning 002 装机后必要的操作 --- 10 实现本地电脑与远程桌面之间复制粘贴(传输)文件
- 在Assets文件夹中放入.sql或.db文件实现创建SQlite表的操作
- 从微软的DBML文件中我们能学到什么(它告诉了我们什么是微软的重中之重)~七 为DBContext对象应该作为其它实体操作类型的基类,并为它提供统一的提交动作
- 遍历树 栈的泛型实现 db操作 读写文件 代码
- svn操作导致桌面文件左下角显示蓝色问号
- android数据库操作之直接读取db文件
- 树莓派 Learning 002 装机后必要的操作 --- 10 实现本地电脑与远程桌面之间复制粘贴(传输)文件
- Linux下SmartGit创建桌面启动器.desktop文件启动不了,而终端里可以运行
- 从微软的DBML文件中我们能学到什么(它告诉了我们什么是微软的重中之重)~七 为DBContext对象应该作为其它实体操作类型的基类,并为它提供统一的提交动作
- 如何在windows下操作虚拟机,如何实现虚拟机和windows桌面文件快速复制
- 如何在window下操作和连接sqlite 的db文件
- Ubuntu 16.04 GNOME在桌面左侧添加启动器(Launcher)
- pandas数据处理常用函数demo之创建/行列操作/查看/文件操作
- 五种Linux桌面操作过程录制的文件
- Android——Launcher(桌面启动器)相关知识总结贴