Android 手机卸载 App 但保留应用数据 作者: Shine 时间: 2025-04-20 分类: Android 评论 比如微信,我是通过国内应用商店安装的,我现在想要安装 Play store 版本的,按照往常可能就需要卸载再安装。 但是我从一些论坛得知其实可以使用 `adb uninstall -k` 命令来卸载 App 但是保留应用数据和缓存。 比如你要卸载微信但是保留应用数据和缓存你就可以这样操作: ```shell adb uninstall -k com.tencent.mm # 如果执行上述命令提示如下内容: # The -k option uninstalls the application while retaining the data/cache. #At the moment, there is no way to remove the remaining data. # You will have to reinstall the application with the same signature, and fully uninstall it. # If you truly wish to continue, execute 'adb shell cmd package uninstall -k'. # 你就执行这个命令: adb shell cmd package uninstall -k com.tencent.mm ```  --- **下面的内容通过 LLM 生成** # 使用 `adb uninstall -k` 命令卸载 Android 应用并保留数据 `adb uninstall -k` 是 Android Debug Bridge(ADB)提供的一个命令选项,允许你在卸载应用时保留其本地数据和缓存。本文将详细介绍该命令的作用、适用场景、注意事项及常见问题处理方式。 --- ## 📌 命令格式 ```bash adb uninstall -k <包名> ``` - `-k`:表示在卸载 APK 时 **保留应用的用户数据和缓存目录**,如: - `/data/data/<包名>` - `/sdcard/Android/data/<包名>` --- ## ✅ 使用示例 以微信(WeChat)为例,其包名为 `com.tencent.mm`,执行以下命令可卸载微信 APK 但保留用户数据: ```bash adb uninstall -k com.tencent.mm ``` 卸载后,再次安装相同包名和签名的应用时,原有数据将会被保留和恢复。 --- ## 🧠 应用场景 - 在调试或测试应用时,希望**保留登录信息、配置文件或缓存数据**; - 想通过重新安装 App 来修复某些问题,但又不想让用户数据丢失; - 在自动化测试或 CI/CD 脚本中清除 APK,但保留状态。 --- ## ⚠️ 注意事项 ### 1. 无法删除保留的数据 当使用 `-k` 参数时,系统保留了 `/data/data/<包名>` 等目录。如果你之后无法重新安装具有**相同签名**的应用,可能会导致这些数据**变成系统残留垃圾**,也**无法通过 ADB 再次删除**。 ### 2. 签名不一致将无法复用数据 你需要使用**相同签名的 APK**重新安装,才能正常访问旧数据。不同签名的版本(如 debug 签名与 release 签名)无法读取原有数据。 ### 3. 系统提示信息 执行 `adb uninstall -k` 后,可能会看到如下提示: ``` The -k option uninstalls the application while retaining the data/cache. At the moment, there is no way to remove the remaining data. You will have to reinstall the application with the same signature, and fully uninstall it. If you truly wish to continue, execute 'adb shell cmd package uninstall -k'. ``` > 这是在提醒你:一旦卸载后签名不同,保留的数据将无法删除或复用。 --- ## 🛠️ 替代命令(推荐) 官方推荐使用更底层的 `cmd package` 命令来保留数据: ```bash adb shell cmd package uninstall -k <包名> ``` 示例: ```bash adb shell cmd package uninstall -k com.tencent.mm ``` 该命令作用与 `adb uninstall -k` 相同,但更加直接调用了系统的 `PackageManagerService`。 --- ## 🧹 完全清除数据的卸载方式 如果你想彻底卸载应用及其所有数据: ```bash adb uninstall <包名> ``` 示例: ```bash adb uninstall com.tencent.mm ``` 此操作将删除 APK 文件以及所有相关数据。 --- ## 📂 检查残留数据 可通过以下命令检查某个应用是否还有保留数据: ```bash adb shell ls /data/data/<包名> adb shell ls /sdcard/Android/data/<包名> ``` --- ## 📝 总结 | 目标 | 命令 | |---------------------------|-----------------------------------------------------------| | 卸载 APK 并保留数据 | `adb uninstall -k <包名>` 或 `adb shell cmd package uninstall -k <包名>` | | 卸载 APK 并清除所有数据 | `adb uninstall <包名>` | | 检查是否有数据残留 | `adb shell ls /data/data/<包名>` | --- ## 🙋 常见问题解答 ### Q: 使用 `-k` 卸载后,无法再次安装应用,提示签名冲突? A: 请确保你使用的 APK 与原版本签名一致,或者先使用 `adb uninstall <包名>` 清除数据后再安装。 ### Q: 使用 `-k` 卸载后,怎么彻底删除保留的数据? A: 只能重新安装相同签名的 APK 后,使用 `adb uninstall` 来完整卸载清除所有数据。
Linux WARP CLI 一直连接不上原因 作者: Shine 时间: 2025-04-15 分类: 谈天说地 评论 Warp CLI 连接需要使用代理如 Clash 并开启 TUN 模式,就会劫持相应的的流量,从而连接上 WARP 节点 最近可能是修改过相关规则,导致一直无法连接很郁闷,然后经过不断排查,终于发现问题,原来是 `cloudflareclient.com` 走了直连导致一直连接不上服务器 最终添加 Clash 规则解决: ```yaml rules: - 'DOMAIN-SUFFIX,cloudflareclient.com,Proxy' ``` 
Cursor 配置 MCP Server 并自动运行不需要手动点击 “Run” 作者: Shine 时间: 2025-04-03 分类: 编程工具 2 条评论 找到 `mcp.json` 配置文件  找到需要自动运行的 MCP Server,添加这个配置 `"autoRun": true` 参数,如图 
JetBrains AI Assistant 生成提交消息 (Commit message) 提示语(Prompt) 作者: Shine 时间: 2025-02-12 分类: 神奇技巧 评论 ### 2025-02-25 > 基于此进行改造:https://andrewian.dev/blog/ai-git-commits ```text Generate a git commit message following this structure: 1. First line: conventional commit format (type: concise description) (remember to use semantic types like feat, fix, docs, style, refactor, perf, test, chore, etc.) 2. Optional bullet points if more context helps: - Keep the second line blank - Keep them short and direct - Focus on what changed - Always be terse - Don't overly explain - Drop any fluffy or formal language 3. Please provide a response in the following format: (): Return ONLY the commit message - no introduction, no explanation, no quotes around it. Examples: feat(auth): add user auth system - Add JWT tokens for API auth - Handle token refresh for long sessions fix(worker/pool): resolve memory leak in worker pool - Clean up idle connections - Add timeout for stale workers Simple change example: fix: typo in README.md Very important: Do not respond with any of the examples. Your message must be based off the diff that is about to be provided, with a little bit of styling informed by the recent commits you're about to see. And must use Chinese ``` ### 2025-02-12 > 基于此项目进行相关改造:https://github.com/guanguans/ai-commit/blob/main/config/ai-commit.php#L238-L263 ```text IMPORTANT: Your response MUST be in Simplified Chinese (简体中文) only. Additional formatting requirement: - Add a space between Chinese characters and English/numbers/symbols (在中文字符和英文、数字、符号之间添加空格) Here are some best practices for writing commit messages: - Write clear, concise, and descriptive messages that explain the changes made in the commit. - Use the present tense and active voice in the message, for example, "Fix bug" instead of "Fixed bug." - Use the imperative mood, which gives the message a sense of command, e.g. "Add feature" instead of "Added feature" - Limit the subject line to 72 characters or less. - Capitalize the subject line. - Do not end the subject line with a period. - Limit the body of the message to 256 characters or less. - Use a blank line between the subject and the body of the message. - Use the body of the message to provide additional context or explain the reasoning behind the changes. - Avoid using general terms like "update" or "change" in the subject line, be specific about what was updated or changed. - Explain, What was done at a glance in the subject line, and provide additional context in the body of the message. - Why the change was necessary in the body of the message. - The details about what was done in the body of the message. - Any useful details concerning the change in the body of the message. - Use a hyphen (-) for the bullet points in the body of the message. Remember: 1. The commit message must be written in Simplified Chinese (简体中文) 2. Always add a space between Chinese and English/numbers/symbols (在中文和英文、数字、符号之间需要添加空格) Please provide a response in the following format: (): Example: feat(tracking): 添加 TrackingInfoService 数据处理逻辑 feat(login): 添加 OAuth2 认证支持 feat(route): 添加 /test 路由 fix(order): 修复订单可以 0 元购的问题 ```
使用 Caddy 搭建 WebDAV 服务端 作者: Shine 时间: 2024-12-24 分类: Linux 评论 ## 安装 安装有 2 种方法,一种是自定义构建,另外一种是从 Caddy Download 页面下载。 本文采用第二种方法从 Caddy Download 页面下载。 1. 访问 https://caddyserver.com/download 2. 搜索 `webdav` 并点击选中 3. 选择对应的平台架构 4. 点击 **Download** 按钮下载  ## Caddyfile 配置 ### 生成 hash 密码 > 生成后待会用的上 * 使用 `caddy hash-password` 交互生成密码 hash * 直接使用 `caddy hash-password -p 12345678` 来生成密码 *12345678* 的 hash(注意 *12345678* 可以替换为你要生成的密码) ### 示例配置 **Caddyfile** ```Caddyfile { order webdav before file_server } :80 { # 仅处理 /webdav/ 开头的 URI handle /webdav/* { # 配置账号认证,防止被公共可获取 basicauth { # 语法:{用户名} {通过 caddy hash-password 生成} # 密码是 12345678 root $2a$14$LAqkx1nX98xpH7qwCPjDqub2vPIwZ5aT9ntVuf1QJnygKDWeD09Nu } # 启用 webdav 服务 webdav { # 定义根目录地址 root C:\Users\Shine\Downloads\ # 定义 Request URI 的前缀,与 `handle /webdav/*` 相对应,不然没办法正常处理 prefix /webdav } } redir /webdav /webdav/ } ``` ## 运行 直接使用 `caddy run` 即可启动, 或者使用 `-c` 参数指定 Caddyfile 具体文件地址 `caddy run -c c:\xx\xxx\xxx\Caddyfile`