Android SQL database organization [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am developing an Android native game, but I have problems with Data Storage.
For a better comprehension think it like as i am developing Clash of Clans, but with Native Andorid.
Now imagine I have to store all datas for Buildings, moneys, troups, ecc in my local phone DB.
I read some guides about SQLite for Android, but i don't really like it. It picks always a Cursor object and i have to create an "Helper" class for each table so I can convert the Cursor into the object I picked.
I want a library or anything else that allows you to do like windows phone c#:
SQLiteConnection conn = new SQLiteConnection(DBPath);
return conn.Query<TABLE_NAME>(SQL_QUERY);
//in this way i have a list of TABLE_NAME items without any casting or similar.
I learned SugarORM and it is really simple and intuitive, but it has no possibilities for ID usage(or at least really restricted) and a lot of other limitations.
And here is my question: is there a way to do it with SQLite without using cursor or with any other library, but still complete of all (or at least the most useful) functions?

check this link they explain the most five popular database and there characterstics

Related

Java model best practices SQL - JSON -VIEW [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
While working on a Java web application I was wondering if my model layer was written as it should be. For instance, let's say we have a table USER in our SQL database which consists of 15 columns. Now, when we SELECT all of the columns with SQL we map it to a Java class, serialize via JSON and send it via network to some View and show it on screen.
In a second scenario, we want to select only 2 columns on screen so we do SELECT c1,c2 FROM USER. Thats where my question comes in... am I supposed to map those columns to a same Java model class? Or should i create a new mapper and class to fit it? Both of the approaches seem to have drawbacks, separate class for each query is more work, but it makes sure you always know what data it contains, rather than checking for nulls or working with optionals, also it prevents you from mapping columns you actually don't need.
What is your opinion? Thanks a lot!
Technically you could reuse the same User class for full 15-attribute as well as partial 2-attribute entity. But that will come with a price. Every time you'll see an instance of User class in the code your will have to think if it's the full entity or the partial? Which fields may or may not be null? This will make it much harder to reason about code.

Design: Abstracting JDBC and datasource to SQL/DefaultTableModel [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
My back-end calls for a dynamic datasource and topology, and my front-end calls for a bunch of app coding that queries the RDBMS. My idea is to walk away from the JDBC API altogether, as it turns out, for any API the app coding couples itself to.
Here's the design idea... On queries, the app code passes in SQL, and receives DefaultTableModel as a result. On updates, the app code passes in SQL (even batches of it), and receives success/failure code (plus error message) as a result.
Would you couple all of your app code to class DefaultTableModel? Would there be a better class for generic, decoupled query result handling? (If I ever need metadata, I can subclass/encapsulate that in with the result) Are there examples out there of this already being done? I do not need more than the above for this application. I don't have extravagant RDBMS needs.
What standard non-JDBC options does the Java API have for holding the kind of data in a ResultSet? I am aware of AbstractTableModel and DefaultTableModel. In any event, it has to be smart enough to associate a class with each column in terms of datatype.

How best to store and modify categorized data in Android [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm fairly new to android programming and have a couple years of university experience in Java. I am planning on writing an app for android that will require me to see what category an item entered belongs.
As an example, if a user inputs 'apple', that data must be placed under a 'fruit' category. So in other words I require a data file that will be able to tell me what category the item is in or alternatively the user can add an item to a category if it is not yet categorised.
I am wondering what would be the best way to store this data. Should I use an xml file, database file, text file or what? It would be necessary to perform look-ups and also insertions.
Thanks in advance
I think this question is more of a personal preference, but I would use XML in this case. You can have the structure predefined with distribution of your app, and modify/write the file at runtime. Its easy to read and understand, and just as easily modified. Simply universal.
Sqlite has its positives in large forms of data, but can be much more complex for something that doesn't need much detail.
<index>
<category name="fruit">
<item>apple</item>
.....
</category>
......
</index>
A simple for loop through the categories, and see if the item is present, else add it.
Hope this helps, happy coding!
Android has SQLite built in...for your purposes I'd go with that.
http://developer.android.com/guide/topics/data/data-storage.html
http://developer.android.com/training/basics/data-storage/index.html

How to search database within less time [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have near about 1 million entries in my database table and
I need to use some logic by which I can search within minimum time,
is there any algorithms or logic by which i can get result within less time.
I tried sorting table alphabetically but till it is taking much more time.
If you have any algorithm or logic then please suggest code in Java.
Looks like you need to ad in index to your database table.
If you tell what database you are using, people can give more specific help.
It dosent matter how much records you have as long as your databse is properly normalised and is having proper index. Having said that, the only difference that will make is how you are using indexes. You cannot do much in java, but your db and its design will play a significant role.

Data Structure for Spatial Agent Based Modeling [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What are some good data structures for keeping track of agents in a two-dimensional, spatial simulation?
I've seen some references to quadtrees (which I understand) and kd-trees (which I don't understand very well).
I'm looking for something through which an agent can efficiently say, "I know my location, and I would like to know which agents are near me (within a certain radius of myself)."
Examples (pseudo-code is fine) would be greatly appreciated.
I'm working in Java.
Well, I'm not sure exactly how it is implemented, but the MASON toolkit uses a discretization algorithm that places agents that are close to one another in the same "bucket" of a hash table. It makes for very fast lookups, as only a few of these buckets have to be checked for each query.
The best thing for you is probably to take a look at the source code here:
http://code.google.com/p/mason/source/browse/trunk/mason/sim/field/continuous/Continuous2D.java?r=529
I have found something called a Bucket PR Quadtree.

Categories

Resources