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
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- What does: "char *argv[]" mean?
- How to populate two dimensional array
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- Function is returning undefined but should be returning a matched object from array in JavaScript
- The rules of Conway's Game of Life aren't working in my Javascript version. What am I doing wrong?
- Array related question, cant find the pattern
- Setting the counter (j) for (inner for loop)
- I want to flip an image (with three channels RGB) horizontally just using array slicing. How can I do it with python?
- Numpy array methods are faster than numpy functions?
- How to enter data in mongodb array at specific position such that if there is only 2 data in array and I want to insert at 5, then rest data is null
- How to return array to ArrayPool when it was rented by inner function?
- best way to remove a word from an array in a react app
- Vue display output of two dimensional array
- Undot Array with Wildcards in Laravel
Related Questions in REACT-NATIVE
- ussd reader in Recket Native module
- I can't make TextInput to auto expand properly in Android
- expo config plugin use import instead of require
- Custom Sound for Expo Push Notifications Only Works in Foreground
- run RTK dispatch on gesture start with React Native
- Should I set Back-End for my React Native application?
- using infoPlist in app.json for expo project seems to not be working
- Anyone have success configuring react-native-home-indicator?
- KeyboardAvoidingView makes a messy the flexbox
- I am getting lots of errors when building react native app in Xcode
- Search and highlight text of current text in PDFKit Swift
- Flatlist Sometimes Capped at 10 Items Bug
- Is there any way to page transition in react native (stack navigation)
- Screen inside Stack.Navigator not visible in React-Native
- React Native stopwatch implementation slow on iOS
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.