简体   繁体   English

有什么方法可以从本地计算机(本地服务器)读取数据库文件并复制到 android 中的资产文件夹?

[英]Is there any way that I can read database file from local computer (local server) and copy to assets folder in android?

@Singleton
@Provides
fun provideDB(applicationContext: Context): myDB{
    return Room.databaseBuilder(applicationContext, myDB::class.java, DatabaseConstants.DATABASE)
            .createFromAsset("sample2.db")
            .fallbackToDestructiveMigration()
            .build()
}

This is my code in which I am reading sample2.db from the assets folder.这是我从资产文件夹中读取 sample2.db 的代码。 I want to read it from the local server and paste it to the assets folder so that I can use it the way I am using it during runtime.我想从本地服务器读取它并将其粘贴到资产文件夹,以便我可以在运行时使用它的方式使用它。 The app should read the file from the local server and paste to the assets folder or update the file if already present.应用程序应从本地服务器读取文件并粘贴到资产文件夹或更新文件(如果已存在)。

You cannot copy something into the assets folder at runtime if that is what you are asking.如果这是您的要求,则您无法在运行时将某些内容复制到资产文件夹中。 You will need to download the file then store it in the file system at runtime您需要下载文件,然后在运行时将其存储在文件系统中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM