title: how to create general method for all type of class(object)
body: <p>I am using db4o lib for storing data.</p>
  
  <p>for example I have this code for storing data (i.e News)</p>
  
  <pre><code>public static void insertNewsToDB(Context context, final News news){
          final String dbPath = context.getDir("news", Context.MODE_PRIVATE) + "/"  + DB4O_NAME;
          ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), dbPath);
          try {
              db.store(news);
              db.commit();
          } finally {
              db.close();
          }
      }
  </code></pre>
  
  <p>and this getting data from db:</p>
  
  <pre><code>public static List&lt;News&gt; getNewsListFromDB(Context context){
          final List&lt;News&gt; news = new ArrayList&lt;News&gt;();
          final String dbPath = context.getDir("news", Context.MODE_PRIVATE) + "/"  + DB4O_NAME;
          ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), dbPath);
          try {
              ObjectSet&lt;News&gt; result = db.queryByExample(News.class);
              news.addAll(result);
          } finally {
              db.close();
          }
  
          return news;
      }
  </code></pre>
  
  <p>How could I create method so it's not depend on what type of class I have to pass. More clearly it doesn't depend on second parameter is News,User or something else. And same when I want get news from db.</p>
  
  <p>I need to create general method which is not depend on type of class.</p>
  
  <p>EDIT: I did this but I doesn't work. More clearly trying get list it returns nothing. And I don't get it why
  what I did wrong </p>
  
  <pre><code> public static void insertToDB(Context context, final Object obj,final String _key) {
          final String dbPath = context.getDir(_key, Context.MODE_PRIVATE) + "/" + DB4O_NAME;
          ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), dbPath);
          try {
              db.store(obj);
              db.commit();
          } finally {
              db.close();
          }
      }
      public static &lt;T&gt; void insertToDB(Context context, final List&lt;T&gt; newsList,String _key) {
          for (T news : newsList) {
              insertToDB(context, news,_key);
          }
      }
  
      public static &lt;T&gt; List&lt;T&gt; getListFromDB(Context context, final java.lang.Class&lt;T&gt; tClass,final String _key) {
          final List&lt;T&gt; news = new ArrayList&lt;T&gt;();
          final String dbPath = context.getDir(_key, Context.MODE_PRIVATE) + "/" + DB4O_NAME;
          ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), dbPath);
          try {
              ObjectSet&lt;T&gt; result = db.queryByExample(tClass);
              news.addAll(result);
          } finally {
              db.close();
          }
          return news;
      }
  </code></pre>