3

I have a SQL Database containing 24 Columns and about 24000 Rows. I want to retrieve data from that SQL Database. I am new to Android and don't know how to use it.

I found an Android library called Realm but I couldn't find a way of Converting SQL to Realm Database.

If there is a simple way to read data from and to store data in SQL Database or another way of storing data in Android in form of Database, please let me know.Any Help will be appreciated.

Thanks!!

Syed Ali Naqi
  • 658
  • 7
  • 14

3 Answers3

1

android uses SQLite. This is very similar to SQL. You would only need to have the app download the data from the server database and copy in into the local database.

SQLite information can be found at http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

Converting from an SQL file has been discussed at Convert MySQL to SQlite

Community
  • 1
  • 1
mattfred
  • 2,583
  • 1
  • 20
  • 36
  • Well yes I have already checked that. But it didn't solve my problem. You See I Have a **24000 Rows** of data in a **.sql** file. How do i read it in the Android from the file??? – Syed Ali Naqi Jun 16 '15 at 22:07
  • @SyedAliNaqi - I have edited my answer to include how to convert your file. Hopefully this helps. – mattfred Jun 16 '15 at 22:33
1

Android comes with SQLite, this is what you should use. did you search anything like "Android and sql"? android training on the subject

Edit: so you dont have an sql file, you have an online MySql database. can use jdbc but it is not widely recomended. there are some alternatives as in here and here

Community
  • 1
  • 1
Skaros Ilias
  • 860
  • 7
  • 33
  • Well yes I have already checked that. But it didn't solve my problem. You See I Have a **24000 Rows** of data in a **.sql** file. How do i read it in the Android from the file??? – Syed Ali Naqi Jun 16 '15 at 22:06
  • so wait, you have the data on the file, or you have the Database? you confused me there a bit. I am no sqlite programmer, but i am guessing you would have to copy your DB to sqlite and use it with your app, or use a internet server to host your DB and connect to that to get what you want. using jdbc for example – Skaros Ilias Jun 16 '15 at 22:14
  • Well I have uploaded my .SQL file to a MySQL Online Database. So Now how do i read data from it, change it or create a new table etc. See I do know a way to retrieve data from MySQL by using JSON, but I don't know how to write to MySQL or Create a Database etc. That's why I Didn't thought of using it.. – Syed Ali Naqi Jun 16 '15 at 22:24
0

Not sure if this will help, but . . .

I have been playing around with different programming options for my Android tablet. One is RFO Basic! freely available from the Google store. It seems to be a dialect of Dartmouth Basic with a lot of built-in hooks to Android specific functions (GPS, camera, etc) as well as an interface to SQL. The set of example programs that comes with the distribution includes and SQL example. Being a Basic-language environment it will (1) be easy to learn but (2) probably slow (very slow) on a 24000 row table..

Hope this helps