我必须以编程方式在android中的drawable菜单中减少抽屉菜单项。请建议方法。我也附加图像。
我有一个应用程序要调试,导航抽屉菜单中有7个菜单。在这些菜单中,我必须通过编写java代码来保留2个菜单。任何人都可以建议。
答案 0 :(得分:0)
Please try this one it is working on swift 3.0
func copyDatabaseIfNeeded() {
//Using NSFileManager we can perform many file system operations.
let fileManager = FileManager.default
let error: Error?
let dbPath: String = self.getDBPath()
var success: Bool = fileManager.fileExists(atPath: dbPath)
if !success {
let defaultDBPath: String = URL(fileURLWithPath: (Bundle.main.resourcePath)!).appendingPathComponent("database.sqlite").absoluteString
do {
success = try fileManager.copyItem(atPath: defaultDBPath, toPath: dbPath) as Any as! Bool
}
catch let error as NSError {
print("Ooops! Something went wrong: \(error)")
}
if !success {
assert(false, "Failed to create writable database file with message '\(error?.localizedDescription)'.")
}
}
}
func getDBPath() -> String {
let paths: [Any] = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDir: String = paths[0] as! String
return URL(fileURLWithPath: documentsDir).appendingPathComponent("database.sqlite").absoluteString
}