There are some ways to record/persist data on Android to retrieve it later, as demonstrated here in the documentation:
The most commonly used are:
Sharedpreferences
Which is a place where you can store values
primitive, key-value format (key-value pairs).
In your case you can serialize the object in json (in String), and retrieve and deserialize it later.
You can use the library gson to serialize and deserialize the object.
To save:
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
Editor prefsEditor = mPrefs.edit();
Gson gson = new Gson();
String json = gson.toJson(listaDispositivoFavorito );
prefsEditor.putString("DISPOSITIVOS", json);
prefsEditor.commit();
To recover:
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
Gson gson = new Gson();
String json = mPrefs.getString("DISPOSITIVOS", "");
Type type = new TypeToken<List<BluetoothDevice>>(){}.getType();
List<BluetoothDevice> obj = gson.fromJson(json, type);
Sqlite Databases
Which is an SQL database for Android. How to use here.
References:
- http://developer.android.com/guide/topics/data/data-storage.html#pref
- http://developer.android.com/guide/topics/data/data-storage.html#db
- https://stackoverflow.com/questions/7145606/how-android-sharedpreferences-save-store-object
- https://stackoverflow.com/questions/20819294/save-custom-object-array-to-shared-preferences
- https://stackoverflow.com/questions/14981233/android-arraylist-of-custom-objects-save-to-sharedpreferences-serializable
Ta is what Bluetooth has to do with history? I didn’t understand anything.
– Fernando Leal
To make an application q need to save the list List<Bluetoothdevice> listFispositiveFavorite = new Arraylist<Bluetoothdevice>(); and then recover when the application runs again
– Pedro Rangel
I get it, there are some ways to record data on Android such as those.
– Fernando Leal
Welcome to Stackoverflow in Portuguese. I believe you should elaborate your question better, I recommend you read "How to ask a good question?" and edit your question to make it easier to understand what you want.
– RodrigoBorth