1

If I download server db file in to my application. Can make my db operations on that file.?

If yes, Can I store it in my application memory.? I would appreciate if you give me a sample example.

Please help..

Thanks.!

user2085965
  • 393
  • 2
  • 13
  • 33

2 Answers2

2

I assume you download a SQLite database file and store it at an accessible place.

You can open databases at specific paths with Android's SQLite API: http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html : SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null, 0); Then you can work with it like with every other database connection, of course.

From a design point of view it is not a very good idea to do this, a structured access to the data via some kind of web service would be better; this would allow the app to react to different methods of storage and make the design independent from specific databases, versions of the database and schemas.

Hauke Ingmar Schmidt
  • 11,559
  • 1
  • 42
  • 50
  • Thanks so much.. Why I am doing this is, I need to download 17 files from server, each file has huge amount of data. If I download one after another file it would take more time. and also I can not make 17 threads which run parallel and download file. I found this DB file process may help in this case. Can you please suggest me on this problem.? – user2085965 Dec 11 '13 at 12:30
  • Sorry, that is too general to make useful suggestion. Maybe in your specific case it is the best idea to download database file. If the files are huge then downloading them parallel will not yield much in terms of time saved. If it is static data (i.e. not specific to the client) you should look into the -market's- play capabilities for additional data download and serving. – Hauke Ingmar Schmidt Dec 11 '13 at 12:45
  • Ok, that downloaded db file is server database file. which is written in .NET. I can make operations on that on that right.? Please look at this link. http://stackoverflow.com/questions/20519858/outofmemory-error-in-arraylist-android – user2085965 Dec 11 '13 at 13:02
  • If the versions are compatible, sure. SQLite files should be independent of the language/runtime used for your execution logic. But mixing .net and Java/Android adds to complexity and fragility. Some stable interface would be better (but is not in the scope of this question). – Hauke Ingmar Schmidt Dec 11 '13 at 13:07
0

Download data from server and store them using sqlite in your application and do operations which ever you want, instead of downloading the db file in you application and try these tutorials for sqlite http://www.vogella.com/articles/AndroidSQLite/article.html http://www.androidhive.info/2013/09/android-sqlite-database-with-multiple-tables Hope that it will work for you

  • Thanks for your reply. I know we can get data from server and store it in our local sqLite db. But can we do the same operations with another external database file.? – user2085965 Dec 11 '13 at 12:20