Md. Robi Ullah
Md. Robi Ullah

Reputation: 2162

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

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?

Upvotes: 2

Views: 738

Answers (1)

Hachther
Hachther

Reputation: 11

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();

Upvotes: 1

Related Questions