title: display data into recycler view from sqlite without restart the app
body: <p>I have a application that contain <code>RecyclerView</code> and <code>FragmentDialog</code> , and I get data from user to <code>sqlite</code> and all is working ,
  but the problem is , when i click into add into <code>Dialog</code>, I have to restart the application to display the data , how I can display the data without Restart?</p>
  
  <p>This is my <code>DialogFragment</code> </p>
  
  <pre><code>public class addAction extends DialogFragment implements View.OnClickListener {
  EditText addTitle, addDesc;
  Button add, clear,close;
  private DatabaseHelpher db;
  String Title,Des;
  public addAction() {
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.addaction, container, false);
      addTitle = (EditText) rootView.findViewById(R.id.todotitle);
      addDesc = (EditText) rootView.findViewById(R.id.tododescription);
      add = (Button) rootView.findViewById(R.id.addbutton);
      add.setOnClickListener(this);
      close = (Button) rootView.findViewById(R.id.Close);
      close.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              dismiss();
          }});
      clear = (Button) rootView.findViewById(R.id.clear);
      clear.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              addTitle.setText("");
              addDesc.setText("");}});
      return rootView;}
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      getDialog().setTitle("Add Action");
      db = new DatabaseHelpher(getContext());
  }
  private void insert() {
      Title = addTitle.getText().toString();
      Des= addDesc.getText().toString();
      db.insertIntoDB(Title, Des);}
  @Override
  public void onClick(View v) {
      if (addTitle.getText().toString().trim().equals("")) {
          addTitle.setError(" Title is required!");
      } else if (addDesc.getText().toString().trim().equals("")) {
          addDesc.setError(" Postion is required!");
      }
      Toast.makeText(getContext(),"your data is saved", Toast.LENGTH_SHORT).show();
      insert();
  }}
  </code></pre>
  
  <p><strong>MainActivity</strong> </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  List&lt;ToDoModule&gt; dbList;
  RecyclerView mRecyclerView;
  DatabaseHelpher helpher;
  private RecyclerView.Adapter mAdapter;
  private RecyclerView.LayoutManager mLayoutManager;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().hide();
      helpher = new DatabaseHelpher(this);
      dbList= new ArrayList&lt;ToDoModule&gt;();
      dbList = helpher.getDataFromDB();
  
  
  
      mRecyclerView = (RecyclerView)findViewById(R.id.AppRecyclerView);
      mRecyclerView.setHasFixedSize(true);
      mLayoutManager = new LinearLayoutManager(this);
      mRecyclerView.setLayoutManager(mLayoutManager);
      mAdapter = new RecyclerAdapter(this,dbList);
      this.dbList =helpher.getDataFromDB();
      mAdapter.notifyDataSetChanged();
      mRecyclerView.setAdapter(mAdapter);
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setImageResource(R.drawable.ic_action_name);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              FragmentManager fm = getSupportFragmentManager();
              addAction add = new addAction();
              add.show(fm,"fragment_edit_name");
          }});}
  @Override
  protected void onResume() {
      super.onResume();
  }
  }
  </code></pre>
  
  <p><code>getdata()</code> method from <code>SQlHelper</code> </p>
  
  <pre><code>  public List&lt;ToDoModule&gt; getDataFromDB(){
      List&lt;ToDoModule&gt; modelList = new ArrayList&lt;ToDoModule&gt;();
      String query = "select * from "+ TODO_TABLE;
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor cursor = db.rawQuery(query,null);
      if (cursor.moveToFirst()){
          do {
              ToDoModule model = new ToDoModule();
              model.setActionTitle(cursor.getString(1));
              model.setActionDesc(cursor.getString(2));
              modelList.add(model);
          }while (cursor.moveToNext());
      }
      return modelList;
  }
  
  }
  </code></pre>
  
  <p><strong>RecyclerViewAdapter</strong> </p>
  
  <pre><code>public class RecyclerAdapter   extends RecyclerView.Adapter&lt;RecyclerAdapter.ViewHolder&gt; {
  
  static List&lt;ToDoModule&gt; dbList;
  static Context context;
  RecyclerAdapter(Context context, List&lt;ToDoModule&gt; dbList ){
      this.dbList = new ArrayList&lt;ToDoModule&gt;();
      this.context = context;
      this.dbList = dbList;
  }
  @Override
  public RecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View itemLayoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.actionitems, null);
      ViewHolder viewHolder = new ViewHolder(itemLayoutView);
      return viewHolder;
  }
  @Override
  public void onBindViewHolder(RecyclerAdapter.ViewHolder holder, int position) {
      holder.Title.setText(dbList.get(position).getActionTitle());
      holder.Desc.setText(dbList.get(position).getActionDesc());
  }
  @Override
  public int getItemCount() {
      return dbList.size();
  }
  public static class ViewHolder extends RecyclerView.ViewHolder  {
      public TextView Title,Desc;
      public ViewHolder(View itemLayoutView) {
          super(itemLayoutView);
          Title = (TextView) itemLayoutView.findViewById(R.id.todotitle);
          Desc = (TextView)itemLayoutView.findViewById(R.id.des);
      }
  }
   }
  </code></pre>