Because it does not work with all objects that have saved on my local Data storage?
If I remove the "fromLocalDatastore ()" it works.
Does anyone know any solution for this?
Midia midia = noticia.getImagem().getQuery().fromLocalDatastore().getFirst();
Image which confirms that the objects are saved in DataStorage site, including including the files:
Ok, I think the problem is that local datastore does not support files at this moment (not sure but as I recall it does not). What you could do is
query the parse.com database
store the image on either internal or external storage, perhaps using the objectId as the name
now you can query the local datastore and easily locate the stored image using the objectId of the retrieved objects
Alternatively the images can be stored as a byte array as this blog suggests: http://www.cumulations.com/blogs/8/Problem-with-ParseFile-in-offline-mode
Related
Im using Real-Time database to storage my users Profiles.
Each of the profiles can contain multiple rooms, where each of them contain their own picture creating a quite complex structure.
Here an example:
To make it easier to store the pictures to the corresponding profile, and room I am changing my pictures Bitmap in android to a String before I parse the object into the Database, and then when I get the object back I transform the String back to the Bitmap.
I was just wondering if this comes with any down cost in the future. Or if this implementation is safe where we put more data in the databases.
With your current database structure as-is, you will run into problems.
With the Realtime Database and this structure, everytime you request "user/SOME_ID", you will download all of the data below it - including your serialized images. Consult the database structure guide for information on how to flatten your data out so this doesn't occur.
Furthermore, I would recommend making use of Cloud Storage for Firebase to store your images in their native binary format rather than serializing to Base64 taking up ~30% more space. Like the RTDB, storage can be secured with rules if you store the files in structured locations like "user/SOME_ID/roomImages/ROOM_ID/..." or "roomImages/ROOM_ID/..."
I think that's not safe and bad implementation because u save users data in a third party service even without any encryption rather than storing it in your back-end which you have full control on it.
if I was A user for your app I didn't like that but if this app just for testing something there is no problem.
Firebase Storage offers some options to get a reference to a file. Among them, I am considering storing a URL so that I can use some caching library like Picasso, as well as to store files inside the device's internal storage (in case the cache has forgotten the image, better to get it from internal storage while it downloads through Picasso again).
To do that, I am storing the downloadURL in the Firebase Database and in my structures. I am wondering if storing the filename as well, and therefore query by the filename rather than by the url would make the retrieval time/performance faster.
So, which of these would be better/faster:
1) FirebaseStorage.getInstance().getReference("filename")
or
2) FirebaseStorage.getInstance().getReferenceFromUrl("https://blabla.com")
I believe the first option would be better, but that depends on how the second option query is structured. Perhaps they are pratically equivalent?
I am developing a places of interest app which will display the list of places of interest in a location.
When user chooses one, it will display more information and address etc.
How do I store all this data? Currently I am using a text file to store all the data and subsequently when user chooses a place, it will parse the text file and retrieve the necessary data for display.
Any advice on what is a better way to do this? I looked at SharedPrefs, but it is more like storing "key-value" pair and in this case I need to store a large amount of data.
I want the info to be available even when the device is offline, thus I can't download from an online server upon request.
Any other way to do this?
You may store it to XML file using XML serializer, here is very good tutorial for learning that,
http://www.ibm.com/developerworks/library/x-android/
and it can be easily parsed using Java XPath Api. Have a look at this at parsing XML files
http://www.ibm.com/developerworks/library/x-javaxpathapi/
Use SQLite
It can store large data.
It is available offline.
All your problems will be sorted out.
Hre we have a wonderful tutorial for sq-lite
http://www.vogella.com/articles/AndroidSQLite/article.html
How about a relational database?
http://developer.android.com/training/basics/data-storage/databases.html
Take a look at Serialization. If you do not need database access, you could define a class what holds every information you need. Then, you can do the following:
when you need to save the datas, you serialize your object, dumping its content to a file, for example on the SD card
when you want to load the datas, you just load the above mentioned file, and get back everything from the dumped file
I am using this method in my app to cache some datas that would need internet access, so the user can still view it, and with proper implementation, this can work very nicely.
Use database, create table and insert all the data in it. When you need the data just fire the query, and you are done.
SQLite is fine for Android.
Depending on the type of data you want to store, you could use a SQLite Database (provided with Android) if it has a normal database structure. You could Serialize your data and save it in a raw or encrypted file, making you data implement Serializable.
I am making an expense log application. The user can create a log by adding a picture of an object and then add the price and some comments to it.
I would like to know if I need to use database to store that data or i can store it directly to the phone.
There are several ways you can store data in Android application: SharedPreferences, files, SQLite databases, etc. Which one you choose, depends on your requirements, amount of data you need to store, etc. I suggest you read Data Storage section in the Android developer's guide to get started.
For your case a databse is the best fit. You could put all expenses in a String array in the SharedPreferences but this would be horrible to use. You would always need to load all expenses to memory if you are searching for one and so on. A database allows searching, filtering and ordering through SQL. It is a bigger initial amount to create the Database but the management of the data will be much nicer afterwards.
Demonick is right about the images, only store the path to the image file in the database and then retrieve the images from there. If you are storing images on the SD-Card the user or other apps can access and delete them so don't count on them to be available later.
Actually i want to know how to store data from my app in the device so that i can review the store data when i run the application again..
means in simple terms i want to say that suppose i have text box where i write some information..now when i click the submit button, this information will be save,so that when i open the application the stored data should be appear in the text box..
In all terms i want to say that i just want to stored data in the way that we are using database for storing data..so please anyone suggest me how that can be done in android.
if possible show with an example
Regards
Anshuman
If you have to store small amount of data, you can use SharedPreferences in Android.
If the data that you have to store is big/complex enough, try using SQLite database.
Still need help?
UPDATE: There's a tutorial that I wrote to demonstrate how to use SQLite database. check it out here. Although it copies existing database into device's memory, but other versions of it, which create database through code can also be devised from it.
A better tutorial is here : http://www.vogella.com/tutorials/AndroidSQLite/article.html
1) If you want to store data in table format then you can use SQLite database in android
2) If you don't want to store data in table format then you can store in SharedPreference
more info about SharedPreference here and here
Android comes with a built in SQLite database that you can use. I advice you to go trough this notepad tutorial. It teaches the basics of using Android SDK including different states of the android application as well as how to use SQLite with Android.
For storing simple key = value pairs, you can use Properties.
For data storage as in a database, you can use sqlite on android.
Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs, such as whether the data should be private to your application or accessible to other applications (and the user) and how much space your data requires.
Your data storage options are the following:
Shared Preferences
Store private primitive data in key-value pairs.
Internal Storage
Store private data on the device memory.
External Storage
Store public data on the shared external storage.
SQLite Databases
Store structured data in a private database.
Network Connection
Store data on the web with your own network server.
Data Storage