Reputation: 2162
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
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