-
Notifications
You must be signed in to change notification settings - Fork 476
[Android] Make db size configurable #98
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
Changes from 10 commits
587c68f
c2d5908
f840a7f
aab59e3
17a953c
3bb688b
d7d6ad0
573777d
93f0ee2
7a5e0d3
230e1c4
0ba4992
0efc595
ed57c1f
1ad778e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,24 @@ | |
import java.util.List; | ||
|
||
public class AsyncStoragePackage implements ReactPackage { | ||
|
||
long mSize = 6L * 1024L * 1024L; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public AsyncStoragePackage(){ | ||
super(); | ||
} | ||
|
||
public AsyncStoragePackage(long size){ | ||
super(); | ||
mSize = size; | ||
} | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { | ||
return Arrays.<NativeModule>asList(new AsyncStorageModule(reactContext)); | ||
return Arrays.<NativeModule>asList(new AsyncStorageModule(reactContext, mSize)); | ||
} | ||
|
||
// Deprecated in RN 0.47 | ||
// Deprecated in RN 0.47 | ||
public List<Class<? extends JavaScriptModule>> createJSModules() { | ||
return Collections.emptyList(); | ||
} | ||
|
@@ -33,4 +45,4 @@ public List<Class<? extends JavaScriptModule>> createJSModules() { | |
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Increase Async Storage size | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd put here sections for platforms, i.e use H2 for |
||
## Android | ||
|
||
Current Async Storage's size is set to 6MB. Going over this limit causes `database or disk is full` error. | ||
|
||
``` | ||
database or disk is full (code 13) | ||
``` | ||
|
||
Disclaimer: This 6MB limit is a sane limit to protect the user from the app storing too much data in the database. This also protects the database from filling up the disk cache and becoming malformed (endTransaction() calls will throw an exception, not rollback, and leave the db malformed). You have to be aware of that risk when increasing the database size. We recommend to ensure that your app does not write more data to AsyncStorage than space is left on disk. Since AsyncStorage is based on SQLite on Android you also have to be aware of the [SQLite limits](https://www.sqlite.org/limits.html). | ||
|
||
### Increase limit | ||
|
||
Modify your `MainApplication.java`'s `getPackages`: | ||
|
||
``` | ||
new AsyncStorage() | ||
``` | ||
|
||
to | ||
|
||
``` | ||
new AsyncStorage(100L * 1024L * 1024L) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a bad practice to pass parameters to // helpers/Storage.js
import {createAsyncStorage} from '@react-native-community/async-storage';
const AsyncStorage = createAsyncStorage(100 * 1024 * 1024);
export default AsyncStorage; |
||
``` | ||
|
||
Where the 100 defines the new size in MB. In this example, new limit is 100 MB. | ||
|
||
|
||
## iOS | ||
|
||
Async Storage size is not limited programmatically on iOS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the link here still correct?