首页 \ 问答 \ 检查Appcelerator区域设置数据库是否存在(Check if Appcelerator locale database exists)

检查Appcelerator区域设置数据库是否存在(Check if Appcelerator locale database exists)

我需要知道应用程序中是否存在区域应用程序加速器/钛数据库,以便能够将数据从该数据库迁移到ArrowDB。

有没有办法找出数据库的名称是否存在?

我试着回答这个问题,但没有成功。 https://archive.appcelerator.com/question/143890/check-if-local-database-already-exists

// SDK 5.5.0 GA。 iOS和Android


I need to know if a locale appcelerator/titanium database exist in an app to be able to migrate data from that DB to ArrowDB.

Is there any way of finding out if a DB exist by its name?

I tried following this answer but didn't succeed. https://archive.appcelerator.com/question/143890/check-if-local-database-already-exists

// SDK 5.5.0 GA. iOS & Android


原文:https://stackoverflow.com/questions/39747084
更新时间:2024-03-08 14:03

最满意答案

你确实使用单身。 简单来说,有两种常见的单例实现,另一种是实例化类,并有一个静态成员引用这个实例。

您的实施使呼叫更简单IMO:

PageAccessChecker.CheckIfRoleAllowed(path);

代替:

PageAccessChecker._default.CheckIfRoleAllowed(path);

You do use a singleton. Simply, there are 2 usual implementations for singletons, the other being instantiating the class and having a static member referencing this instance.

Your implementation makes calls simpler IMO :

PageAccessChecker.CheckIfRoleAllowed(path);

instead of:

PageAccessChecker._default.CheckIfRoleAllowed(path);

相关问答

更多
  • 选择单身优于静态类的一个很好的理由(假设你没有更好的模式可供使用)),就是将一个单例实例与另一个实例交换。 例如,如果我有这样的日志类: public static class Logger { public static void Log(string s) { ... } } public class Client { public void DoSomething() { Logger.Log("DoSomething called"); } } 它工作得很 ...
  • NullPointerException引用您的Boolean而不是单例实例。 您将boolean的初始值设置为null,那么可能发生的是您的GameData被创建,但布尔值尚未设置。 使用默认值更改为基本类型布尔值应该可以解决此问题。 可能导致这种情况的一种可能的情况是例如方向改变。 这将删除无效的GameData对象,强制它被重新创建(当调用getInstance() )。 但布尔可能不会在下次访问它时设置。 The NullPointerException is referring to your B ...
  • 简短的回答: 没有 。 单身人士解决资源争用问题。 对于SQL连接没有争用,您可以根据需要创建任意数量的连接。 关于使用单身人士的更多细节在这里:单身人士有什么不好? 正如其他人所说,使用连接池更好。 连接池也会获得更好的性能。 关于连接池的好处: 为什么我们需要连接池用于JDBC? Short answer: No. Singletons solve Resource Contention problem. For SQL connection there is no contention, you ca ...
  • 这不是真的是一种情况。 单身人士是具有静态获取者的实例,以及一个私有构造函数。 它们不是静态类。 带有某些限制条件的单身人士是确保你只有一个班级实例的一种方法。 所以第一个问题是。 你是否需要一个实例,即这个事物是否有状态,第二个问题是他们进行单元测试有多困难,你是否想要一个实例。 例如,查看Service Locator模式。 This is not really an either or scenario. Singletons are instances with a static getter, a ...
  • 您需要从cpp文件中的定义中移除static :编译器已经知道Singleton::Instance和Singleton::Destroy从它们的声明中是static的。 其他一切都看起来不错 You need to remove static from the definitions in the cpp file: the compiler already knows the Singleton::Instance and Singleton::Destroy are static from their ...
  • 显然,第一种方法更简单,更短 - 无论是阅读还是性能和记忆方面。 在第二个代码中,两个额外的构造将导致一点开销。 Clearly the first approach is simpler and shorter - both for reading and definitely in performance and memory aspects. In the second code, the two extra constructs will cause a little overhead.
  • 你确实使用单身。 简单来说,有两种常见的单例实现,另一种是实例化类,并有一个静态成员引用这个实例。 您的实施使呼叫更简单IMO: PageAccessChecker.CheckIfRoleAllowed(path); 代替: PageAccessChecker._default.CheckIfRoleAllowed(path); You do use a singleton. Simply, there are 2 usual implementations for singletons, the ot ...
  • 你需要首先分配和初始化数组。 就个人而言,我会在内容类的init方法中这样做: -(id)init{ if(self = [super init]){ …the rest of your init code… contentArray = [[NSMutableArray alloc] init]; } return self; } You need to alloc and init the array first. Personally I' ...
  • Yoy说“单身类”,我认为你的意思是这个类只有类方法。 没关系,你仍然可以使用它,因为类对象仍然是对象。 也就是说,你可能需要保持状态。 每个委托调用都将包含一些允许对象识别发件人的参数。 我自己可能会做的是在“initialize”方法中创建一个NSMutableDictionary,然后在发送委托方法之前让对象注册自己,当他们注册时创建另一个mutableDictionary,并在第一个以发送对象作为键保存它(或其他一些独特的标识符)。 每个委托调用都必须包含发件人,然后您可以检索与该对象关联的字典。 ...
  • 拥有静态属性并没有错,但在单例中它是多余的。 此外,如果您有静态属性,稍后您需要将类更改为不再是单例,您还需要更改属性(作为访问它的每个代码)。 所以除非真的需要,否则我建议你不要标记为静态。 It's not wrong to have static properties, but it's redundant in a singleton. Also, if you have static properties, and later you need to change the class to not ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。