开发者

class accessible from all other classes

I have some database functions and would like to make those database functions a开发者_开发百科ccessible too all of my other classes. I would like to keep the functions in one place so they are easy to modify. What is the best way to achieve this goal? My application is running on android and is using threading and events.

Thanks in advance, if you need more information let me know.


  • make a class with all static methods/variables, or alternatively a Singleton
  • synchronize stuff if you need to, sounds like you might


Absolutely no reason why you can't have a package level class called something like DatabaseUtils and put general static methods in there. Doesn't have much bearing on it that you're using threading and events, although you will want to ensure your utility methods can handle simultaneous access if that's a possibility.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜