How to export/import data on Android - android

I have an application that stores data in SQLite db. I've implemented export of this data to external file (in json format) with custom file extension. Also I have an activity that starts when user opens my file and saves it back to SQLite.
I don't want to backup my db, I'm exporting a part of data to be used by another users.
My next goal is to make sharing this data via Bluetooth (export it to Dropbox / send via email). I want it to look like described in this tutorial: http://developer.android.com/training/sharing/send.html but I doubt that this tutorial is what I need.
I don't want users to export data to file and then send this file via Bluetooth, I want them to share data directly from my app.
I looked at FileProvider. I'm confused with insert, update and other methods so I'm not sure this is the right choise.
I looked at Sending Binary Content tutorial but I don't know how to create intent properly and how to save my temporary file for sharing.
Please, describe the way to share this type of data or give me links to examples. Thanks!
P.S. sorry for my English

Related

how to manage data for view immediately after database file is imported into web application?

My title might have explained you a lot. But still I explain you in a use case way. In my web I have a database file that I insert data using form. I know, it is possible to see the data easily. After that, I export the same database file into my work station and then from there I import the file to android application. That database file is used for CRUD operations. When everything is done the same file is again imported to the web app and merge the two database files (web app database file and android database file) to be one and manage for the views of data.
Now, the question is that am I able to see the data from that merged file immediately after I import. When I import database file to web app, two files merge to one and then only data can be viewd. I can merge the two database files by coding but for the view is the system responsible? Or, how can I do it fast? I mean I import file and after that I want to see changes of data in my view of web app.
I hope some one lead me to right direction. Only logical answer is required. Please do not suggest me another way to do because this is the only one way I want to do. Thanks in advance :)!!
I hope Server-sent events will be more opt in your criteria. (ie) Whenever you have a database update in your server side (using code or any), you need to trigger a "Server-sent event" so that it will be sent to your clients and make them request for view update or directly update through the trigger message.
Please check this QA for more clarification.
Server-sent events

Android ContentProvider with JSON files

How do I implement a ContentProvider with a JSON file? My goal is wanting the contents of a json file (or the file itself) from one app to be transferred to another app. Android documentation says it can be done with BLOBs but I have no idea what that means, and all of their examples are referring to SQL databases, which my app doesn't use (all data is stored in one JSON file).
My goal is wanting the contents of a json file (or the file itself) from one app to be transferred to another app.
To literally do this, use openFile() on the ContentProvider side and openInputStream()/openOutputStream() on the ContentResolver (client) side.
However, I suspect that this is not an especially good idea. JSON is not a data storage model that will work will with multiple simultaneous accessors. IOW, when both apps try to work with the JSON at the same time, who wins and loses?
Also, what happens if the app hosting the JSON file is uninstalled? Now the other app has no more access to the data.

Android: How can I share SQLite table with another phone with the same APP

I am thinking regarding the future options of my app and I am thinking of the idea of backing-up the data from the application's Database and also sharing that data with another phone, say via e-mail, messaging, Bluetooth, you name it, but basically saving it as a file and opening it from the other phone and having the same values on both phones.
What would be the best approach for such an Android application?
Would Content Providers accomplish exactly this or are they concerned with sharing data only between different Apps? Thanks!
I believe it is possible ,
If you read the documentation about the internal storage here, It mentions
You can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them
So i believe you can copy the whole sqlite DB file to some temp location then share that file via BT or email or any other sharing option .
But DO NOTE, that the same application package can only access the file if you want perhaps another application to use the db then u need to set the SharedUserId , as mentioned here
Content Providers are generally only for sharing your app's data to other apps.
Content providers are the standard interface that connects data in one process with code running in another process.

How to write the text file after received the location?

I'm implementing the application just like tracking the user's traveling.
Now I'm using the SQLite database which is record the location, time,and date
then automatically send to the MySQL server via JSON if the Internet is connecting.
But I want to do like the following:
1) I would like to keep data as a text file of each traveling before send to server.
2) I don't know that I should record data in SQLite before write as a file or not?
3) I also need to list all files in the document menu to show user all files
and check the status of all files are completely sent or did not send.
I tried to search for the good tutorial and any examples but did not find them yet.
If anyone have a good tutorial for write/read file and any idea for these, please suggests me.
Thank you so much
Here is good tutorial how to write data to file and save it to SD card.

Android log in and download csv file

I am writing an Android app and I need to download a csv file for a graph. I am not sure if I need to either put the two columns to two array strings or import them to the DB then just query. I am leaning towards just putting them to strings since the csv file will change constantly.
My two issues are:
I need to log into a specific URL to populate the CSV with the correct data such as http://myurl.net/protect/module_graph.htm?log=02. That will populate the file http://myurl.net/protect/data1.csv with the data for the correct item. Changing the log=02 to log=03 or any other number changes the content of the data1.csv file. When I pull up the first URL in a web browser it pops up a window asking for basic authentication. How do I need to call the URL to send the username and password with the request?
I need to get the CSV file downloaded and have the two columns output as strings so the graphing code can just read the data from the strings. I think I know how to download it but should I store it to the SD card and then output the data or just open the file from the web and then output the data? Also how do you tell it to put each column to an arraystring?
Any help is appreciated. Code examples or links to tutorials or other options are much much appreciated :)
Thanks!
You never say it, but I assume you are developing an Android app:
Use HttpClient GET with authentication: an example.
Again use HttpClient GET and look at the reply.

Categories

Resources