use data stored in android sqlite database as input to weka - android

I am not sure if anyone has ever tried this. I am currently storing attributes in a sqlite database on android. What I want to do next is to retrieve these data and apply Machine learning algorithms implemented by Weka. Weka can indeed take data from databases using JDBC. But can this be done with android? The SQLite database in android doesn't seem to be a normal SQLite databse.
I have read this http://weka.wikispaces.com/How+do+I+connect+to+a+database%3F, but it doesn;t help much.
Thank you

I do not think there is a ready implementation for Weka to read the data from sqlite on Android, because the helper class mainly depend on JDBC which is not available for android.
I can think of two options to achieve this:
Query the sqlite database on Android and create Weka training instances programatically on the fly. This solution might be more suitable for online training and when you have large dataset.
Export the training data from sqlite as csv file and pass the file to Weka for training.

It seems that WEKA won't work on Android without changes. J48, for example, requires the java.lang.Cloneable interface, which is not available in Android.
This is a weka port to android project here.
Hope it will help you.

Related

Android Studio & Kotlin - Database to use?

Advise on which database on Android Studio and Kotlin
I am struggling on developing an app using Kotlin using Android Studio.
The app will have 50-100 keys/ids (lines) with each row containing ~10 pieces of data (name, dates, etc.), that can be searched through and the results shown on the app.
As I would like this to be fairly simple, what database should I be using? XML, SQLite, MySQL, etc?
Are there any simple examples that I could use please?
Really appreciate any help.
If you're looking for an offline/local database, you can use room DB instead of SQLite to avoid usage of too much boilerplate code to convert SQL queries and data objects.
You can check this link
https://developer.android.com/training/data-storage/room

How to use SQL Database other means of Data Storage

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

Database inside of Android

I wonder whether there is a way to store data in like a MySQL inside of Android OS.
I have more complex data that I need to save and I dont think SharedPreferences will work.
Is there a predefined way, and how can I access it? Is it in SQL?
Of course there is. On Android each application has own place for database (SQLite). Read http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html
for further details. It's really easy to maintain
Yep, there is SQLite
Here is a question asking for examples.
Here is the SQLiteDatabase class. Goo start point.
well there is SQLite database which is very light weight database to store data in android..
Edit
when you start working with SQLite on android you should not mix it up with MySQL or PHPMyAdmin or any other complex database structure. SQLite is just about storing some information on your device internally and accessing it for some purpose. It is not used for complex database tasks that you do in PhpMyAdmin.
Rather you should visit the links given by #Vee in the answer.

Using Rest to store data in Sqlite

I'm creating my first android app that will make use of SQlite. I have zero experience with databases, except for creating a mysql database to use with wordpress...
Edit: After doing some research about rest, I'm still confused about how rest, sqlite, and android dev fit together. My goal is to access a rest-based web service through a url and access certain datasets, then store them in my SQlite database. Then I want to access the contents of the database through my java program, and use them accordingly.
The datasets can be downloaded individually in CSV format, but because I will be using so many of them, I don't want to go through every line individually and store them in the database. I'm hoping there's a more efficient way to store these datasets in the database.
My main questions are:
How can I copy the XML contents of a webpage from a url into my sqlite database? Can I do this with my java program, through the sqlite database, or a java library?
Do I only need to copy the contents of the webpages from the url into the sqlite database one time? If so, what can I do if any information is changed in the datasets?
You first need a schema for your sqllite DB. That schema should map to the objects behind the web service. For e.g, you need a Person table in your DB if there is a Person entity on the web. It depends on what all you want to capture.
When you are done designing the schema, you should start writing the code that help you create & manage DB on android. This is done with the help of SQLiteOpenHelper class:
http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html
If you need to keep the DB synce'd with the data on the cloud (web services), you should implement sync. Android provides a very efficient sync framework.
Also, do watch this video from Android engineers explaining the best practices: http://www.youtube.com/watch?v=xHXn3Kg2IQE
Note, to actually fetch the data from the web service you would use UrlConnection API:
http://developer.android.com/reference/java/net/URLConnection.html
This sample probably captures most of it.
http://developer.android.com/resources/samples/SampleSyncAdapter/index.html
In terms of reading CSV files, there are some good resources here:
Can you recommend a Java library for reading (and possibly writing) CSV files?
Once you have read each CSV line into an object, then you can turn around and persist it to the database. I'm the author of ORMLite so I'll talk about using it. I don't believe there is a hibernate port for Android.
There are a number of Android examples to help you to get up to speed with ORMLite. Also some good tutorials. If you want to write a number of rows at once then I'd recommend using the batch tasks ORMLite feature. For information, see the discussion about creating lists of objects on the mailing list.
I can answer your first question about " I'm not sure how to add them efficiently"?
yes, SQlite is very powerful and intelligent, you can add thousand of records in one transaction, just like traditional database, It significantly improve performance.
about second question, as my understanding, because CVS file is very simple, so you can download and analyze it by yourself.

Can I use MySQL with Android or do I have to use SQLite?

When using a database for an Android application, is it possible to use a MySQL database, or do you have to use SQLite?
What I'm trying to do is make an app that allows users to see events on a map. These events are updated by admin staff from the office from a Java-based application that works with the MySQL database.
SqLite is present on the phone with some good tutorials out there to get you started using it.
Check the online docs for more details, and I suggest taking a look at the notepad sample, it will get you up to speed in no time.
http://developer.android.com/guide/topics/data/data-storage.html#db
As far as I know you have to use sqlite. MySQL needs a server which would mean you'd need a locally hosted mysql server on a phone which is going a bit overboard.
you have to use sqlite for your android side database
The best is to use content providers if you want to share information. Android provides built in interface for sqlite (android.database.sqlite) and so sqlite is easiest to use.
Another alternative to Sqlite is Berkeley DB for Android (Berkeley DB - Java Edition)

Categories

Resources