How can I access react native asyncstorage data from native(android and iOS)?

Viewed 394

I need to get app data from native code which is stored by asyncstorage in react native. So there is any way to get asyncstorage data from native code?

1 Answers

You can perform reading operations on android with two classes: AsyncLocalStorageUtil and ReactDatabaseSupplier;

import com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil;
import com.reactnativecommunity.asyncstorage.ReactDatabaseSupplier;
String value = null;
SQLiteDatabase readableDatabase = ReactDatabaseSupplier.getInstance(context).getReadableDatabase();
try {
    id = AsyncLocalStorageUtil.getItemImpl(readableDatabase, "key");
} catch (JSONException | NullPointerException ignored) {}

readableDatabase.close();
Related