Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 上的 AsyncStorage的大小限制 #2

Open
Aliveing opened this issue Sep 5, 2018 · 1 comment
Open

Android 上的 AsyncStorage的大小限制 #2

Aliveing opened this issue Sep 5, 2018 · 1 comment
Labels
question Further information is requested react/react-native react or react-native

Comments

@Aliveing
Copy link
Owner

Aliveing commented Sep 5, 2018

问题描述

在Android上使用持久化储存的 AsyncStorage 时,发现catch到一个错误:database or disk is full,这个让我陷入沉思,我存了啥进入?不就是几百个远程链接的图片(80*80)转成的base64码??然后经过查看参考链接后,发现 react-native 在 Android 上设置了默认的 AsyncStorage 的大小限制(6M)

问题发生时相关组件版本

  • react-native 0.56.0
  • react 16.4.1
  • react-native-storage

发生设备

Google Nexus 5x (android 7.1.0, API 25 1080 * 1920)

代码

参考链接

react-native #3387

参考链接即可解决

我是在 MainActivity.javaonCreate 方法中加的:

// NOTE: 设置Android AsyncStore的最大存储量:80M,RN默认为6M(真小气...)
ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(80L * 1024L * 1024L);

2018-09-13 23:00:29 补充


近期又遇到和AsyncStorage存储相关的问题了,故补充
单条数据组存储大小不能大于 2M, 如果超过 2M 就会catch到一个错误: Couldn't read row 0, col 0 from CursorWindow.

参考链接

react-native #12529
更深入了解 2M 大小限制的问题

解决办法

因为我单条数据很大的原因是,单条数据中存储了多个图片的base64码,所以用 rn-fetch-blob 下载图片,单条数据中仅存储返回的本地图片路径即可

@Aliveing Aliveing added question Further information is requested react/react-native react or react-native labels Sep 5, 2018
@Aliveing
Copy link
Owner Author

Aliveing commented Sep 5, 2018

至于 issue 中提到的 不就是几百个远程链接的图片(80*80)转成的base64码,可以用以下两种方式实现:

个人推荐第一种,省心,方便,快捷,主要是代码写的少,第二种比较适合做一个类似云盘管理的鬼(心累)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested react/react-native react or react-native
Projects
None yet
Development

No branches or pull requests

1 participant