Reputation: 24777
I want to use the email as a data storage.
Here's what I want to do: make my android application send its private data as an email attachment, and then reimport this attachment and save it.
For the first part there should be no problem, but how about the second part?
Upvotes: 1
Views: 869
Reputation: 2101
I don't know if it would work with email, but you could try it.
Sending Files to your application
Use an intent-filter to register your application as being able to handle files of a specific type. You'd have to figure out what intent to use but i think ACTION_SEND is probably the one you'll need. You'll need to specify the mime-type to only handle the type of your application data.
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Once you've setup an intent filter you should be able to long-click on files in other applications and export/send them to your application.
Handling Files that have been sent
In the acitivity that has the intent-filter assigned to it, you'll need to capture the data from the Bundle in the onCreate method. See this tutorial: http://developer.appcelerator.com/question/122137/is-there-any-hope-to-get-file-from-intent-uri-receive-outside-of-the-application
Figuring out what intent to register
There may be a way to do it in an emulator, but I installed aLogcat on my phone to do it. When you long-press a file and choose export, you'll get list of options to choose from. Select any application from it. Go to logcat and it will show you what intent was sent to the application you called. It would say something like this START {act=android.intent.action.SEND typ=application/vnd.ms-excel cmp=[class that is being loaded goes here] (hasExtras)}
Upvotes: 2