[英]class accessible from all other classes
I have some database functions and would like to make those database functions accessible 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. 我的应用程序在android上运行,并且正在使用线程和事件。
Thanks in advance, if you need more information let me know. 在此先感谢,如果您需要更多信息,请告诉我们。
Absolutely no reason why you can't have a package level class called something like DatabaseUtils
and put general static methods in there. 绝对没有理由你不能拥有像DatabaseUtils
这样的包级别类,并将常规静态方法放在那里。 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. 虽然您可能希望确保您的实用程序方法可以同时访问(如果可能),但您对使用线程和事件没有多大影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.