简体   繁体   中英

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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