I want to save houses in an array using AsyncStorage. Each array element represents a house Object. And each house object has a latitude, longitude and a house number. I am not sure how to go about representing this. It seems to me that AsyncStorage is not well-suited for saving dynamic objects that can be updated programmatically. I want to be able to add more houses and delete some houses. Basically what I am trying to do is bookmark some houses and delete them from the bookmarks when the user clicks. Can anyone help ?
React Native AsyncStorage
2k Views Asked by jungleMan At
2
There are 2 best solutions below
0
Estuardo Estrada
On
You need a Sqlite alternative like Realm, it's free, fast and easy to code, with this you will save tons of hours of work, also as you need, you can make queries, update and delete objects.
Related Questions in ARRAYS
- Two different numbers in an array which their sum equals to a given value
- how to fill out the table with next values in array with one button
- How to sort a multi-dimensional array by the second array in descending order?
- Looping over defined array elements in Fortran
- Array appending after each onclick and loop in javascript
- PHP : How can I check Array in array?
- store numpy array in mysql
- Java Assign a Value to an array cell
- Saving FileSystemInfo Array to File
- Notice: Undefined offset: 1, but there is such offset
- How can I determine the index of the same set of characters between two strings that are of different lengths?
- Caused by: java.lang.ArrayIndexOutOfBoundsException: length=8; index=8
- Pull out first occurrences from array
- How to read a file then store to array and then print?
- C++ won't read in scientific notation data from a .txt file
Related Questions in REACT-NATIVE
- React Native: detect if UIVisualEffectView is supported
- Prevent Chrome debugger from stealing focus in React Native
- React-native upload image to amazons s3
- react-native update NavigatorIOS component's props
- promise – can't find variable process
- Using React Native within existing iOS app for some views only
- What is a good approach to building and distributing a React Native iOS component that extends iOS functionality?
- error in xcode 6 "is not registered as a URL scheme. Please add it in your Info.plist"
- DeviceEventEmitter stops emitting events to application when screen locked
- How to rename react-native entry file (index.ios.js)
- react-native component lifecycle methods not firing on navigation
- How to use comments in React
- react-native propagate changes in props through ListView and Navigator
- How do i use the iOS shake gesture with react native?
- TouchableHighlight won't accept press events while keyboard is open
Related Questions in ASYNCSTORAGE
- what is AsyncStorage (react-native)?
- How to store data inside an iOS-based CMS app?
- What is the correct way to use AsyncStorage to update state in React-Native?
- Call a async function to store accessToken during authentication React-native
- React Native AsyncStorage
- How to store values in session using React Native?
- AsyncStorage React Native save an Array
- Save a single string in React Native iOS and Android expo app
- No visible @interface for 'RNCAsyncStorage' declares the selector
- how do I implement the "remind me later" button using async storage?
- Why am i getting an undefined output when I try to access value returned from async method
- React native store tokens, with web, android, ios compability
- Trouble updating Picker component from Async Storage in React Native
- AsyncStorage access in Material Top Tab Navigator React Native
- React-Native Async Storage returns weird object with correct value in two consecutive lines
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
AsyncStorage is absolutely perfect for this.
Starting with the structure of your houses, I would create an Array which stores objects representing an individual house.
Saving to AsyncStorage
When you want to write your collection to
AsyncStorage, you would do so like this:You can also use
async/awaitif your project is set up to support it.Reading from AsyncStorage
Reading your collection back from
AsyncStorageis simply done via:You could set the response in your state, do as you please.
Deleting a specific house
This depends entirely on how you set your app up. Are you going to
mapthrough each house and create a list component for example?(Sorry about losing the border on the right)
If so, you could:
Then create a
deleteHousefunction which will handle it.And finally a
saveHousesto sync it back to AsyncStorage. The function will clear AsyncStorage and then save the new houses.