Skip to content

Instantly share code, notes, and snippets.

@709924470
Created September 5, 2025 10:38
Show Gist options
  • Save 709924470/5eaa4f452f23f78300315d4b0bd0f102 to your computer and use it in GitHub Desktop.
Save 709924470/5eaa4f452f23f78300315d4b0bd0f102 to your computer and use it in GitHub Desktop.
MIUI Gallery Favourites Extractor

This method has been tested with com.miui.gallery version 2.3.1.2

  • Get /data/data/com.miui.gallery/databases/gallery.db with a file explorer of your choice
  • Pull the file to your PC (optional)
  • Open the .db(database) file with your SQL inspector of choice (personally recommend dbeaver)
  • Execute the following query
select distinct(COALESCE(pth, lf)) as filePath
	from (select f.isFavorite isf, f.dateFavorite df, f.sha1 fs, f.cloud_id as fi from favorites f where isf == 1) as ff
	left join (select cloud.thumbnailFile pth, cloud.localFile lf, cloud.sha1 as cs, cloud._id as ci from cloud) as cc
	on cc.ci == ff.fi or cc.cs == ff.fs
	where not (pth is NULL and lf is NULL) and not (pth == '' and lf == '') order by ff.df desc
  • Have fun with your extracted data :)
@709924470
Copy link
Author

补个中文介绍, 虽然是个很简单的事但还是没看到有人说过

小米 MIUI 相册收藏提取方法

仅在 MIUI 相册 2.3.1.2 测试过

  1. 从上述位置找到数据库文件, 并提取到手机的任意地方
  2. 将数据库文件提取到电脑 (可选)
  3. 使用你喜欢的数据库编辑器, 打开已提取的文件
  4. 执行上述查询语句
  5. 搞个tmux或者什么的把所有对应的文件scp出来 想怎么用就怎么用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment