If you want your selected images to be stored even after destroying app, Why not just use SharedPreferences. Simply put your file path in Shared preferences.
Code:
public class save
{
SharedPreferences sharedPreferences;
Context ctx;
public save(Context ctx,String file)
{
this.ctx =ctx;
sharedPreferences = this.ctx.getSharedPreferences(file,Context.MODE_PRIVATE);
}
public void store(String key,String value)
{
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key,value);
editor.commit();
}
public String read(String key)
{
String v= sharedPreferences.getString(key, "nothing");
return v;
}
public void remove()
{
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
}
public void delete(String str){
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(str);
editor.commit();
}
public Map<String, ?> readall(){
Map<String, ?> allEntries = sharedPreferences.getAll();
return allEntries;
}}
To add selected path to shared preferences use method store();
to delete a path from shared preferences use method delete();
to remove all use method remove();
to read all use readall();