Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write to localStorage from Java on Android

Tags:

android

I am looking into the http://developer.android.com/reference/android/webkit/WebStorage.html API but it does not support writing to localStorage from Java. What I would like to do is to store data from the Java side of an android application to be read by the JavaScript side of the app.

For instance, in JavaScript I can use localStorage.getItem(), localStorage.setItem(). However, I cannot find similar API to accomplish the task from Java. Is there a workaround or it has not been implemented by the Android platform yet?

Any help would be appreciated!

like image 604
Bai Avatar asked Nov 03 '22 23:11

Bai


1 Answers

There are many ways to store data in an Android application, as detailed in the Storage Options guide:

  • Shared Preferences - simple key/value pairs specific to your application. This is probably the closest to WebStorage.
  • Internal Storage - read/write files
  • External Storage - SD card file storage
  • Databases - better for large amounts of structured data
  • Network - obviously, you can store/retrieve data remotely if needed
like image 65
ianhanniballake Avatar answered Nov 14 '22 04:11

ianhanniballake