Uploading data from Android App to desktop program - java

I'm pretty new to android so apologies if I'm missing an obvious solution, I'm developing an android app that would be used to record various data including photographs and hopefully the intention would be for this collected data to be uploaded to a desktop application where certain desktop specific jobs could be carried out.
Due to the fact I intend to save photographs within the app in the SQLite database as a bytearray which recorded information would be I think that it would be too data intensive to send to a server, plus I wouldn't want the desktop app to necessarily be on a server, it should be standalone. I'd prefer to use the USB connection and allow a USB upload of the data from the app sqlite db direct to the database on the pc, probably sql server. What would be the best way to approach this? Could the android ADB be used to acheive this?
Any help or suggestions on this would be much appreciated.
Regards

I believe that your sqllite database (as well as photos contained there) will be stored on the SD card of the device. You have to options here, first, when your desktop applications find the folder on the device SD card (should be mounted on the filesystem after connecting the device to your PC), second is to use bluetooth and initialize the transfer from the device to your desktop application.

You could try having them on the same network and having them interact that way. I know applications such as RemoteDroid do this, but I have no experience doing so myself. There is also the fact that there is the data saved on the sd card / by putting your device in Storage mode and you could just point your desktop to the device drive and assume a designated folder your app uses exists.

Adding on to the answers here, you could save your photos as files in your sd card and transfer it to your pc from there.
Here is a dev guide on storing files.
Another way is to transfer over WiFi. Ice cream sandwich seems to have a WiFi Direct api that allows us to perform P2P transfers over WiFi. I have not used it yet but have a look at this

Solution 1
I would probably use rsync between my desktop and android. This way you can export data from your sqlite to a flat file and import it to your local database on your desktop. This way you can also put your schema into a file.
RSync is a very stable protocol to exchange files.
Solution 2
You can also use Amazon S3 for this purpose. The file name can contain the version number for ensuring that you have the latest file.

Related

How to write files to your desktop with the use of an android application using an emulator or USB-connected device using for example Android Studio?

I wrote some classes for my Android-program and it runs. However it takes too much ram because the data in the File is not in a nice form to be processed by the application. Let's call the File Foo.txt for now.
I now want to save the data from Foo.txt in a different form which lets my Android specific code (specific in the sense that it uses Activities, Context etc) do easily since I have all the code for it already, and then load from this data manipulatedFooFile.txt instead. Problem is, I don't know if it's possible at all to save to a file which I can then later retrieve on the desktop, either in an emulator or via a device connected to an USB or a way I don't know of yet. This way I can replace Foo.txt with manipulatedFooFile.txt which would let me use less ram and space on disk.
I know that one other solution would be to remove the code from android and put it into a normal java program. Put that would take a bit of struggle since I have to remove all the dependencies on code that is not there, or start with nothing and write big parts of the code again.
Files and folders can be sent to and from your android device using adb (or android debug bridge).
Using the adb pull command under the syntax adb pull <remote> <local> you are able to transfer a file from the filesystem of the connected android device to your local device (your computer).
From the official documentation for adb pull:
Copies a specified file from an emulator/device instance to your development computer.
Similarly, adb push allows you to push a file from your local computer to the target emulator/android device under the syntax adb push <local> <remote>.

Transfer files from android phone to PC automatically

I have an program on PC that sorts and organizes various types of files into a database and does some stuff with this data. It's a hassle to add photos though (Take photo, load to Google drive, download on PC, add to program) so I'd like to have an app that takes a picture and queues it to be added to the database next time the phone is connected to the desktop.
I can't figure out a way to access my phones root folders in Java though since I can't assign a drive letter to it. I've done some research, and it doesn't appear that my phone (Nexus 4) has that capability without some rooting or modding. Is there any way I can use java to detect when the phone is connected and access root folders?
I know the other option is via a network connection between the two devices, but I have 0 networking knowledge so it seems a bit audacious at this point to attempt that.
Thanks
While not exactly what you're asking for, since it doesn't do it when you plug the phone into the desktop, take a look at PushBullet, you can use it to send anything from your phone to your computer (or any other device for that matter) and viceversa.

External Storage Not Mounted

I am still quite new to Android development. I'm trying to take a photo using the camera and save it to the devices storage. The app was crashing and after debugging I realised it's because the devices external storage is not mounted. How do I handle this? Can I mount the storage or is my app just unable to store data on this particular device?
Thanks
Update:
There was an answer chosen to this question but it seems to have been deleted... It linked me to these docs: http://developer.android.com/reference/android/os/Environment.html
Make sure you are using Environment.getExternalStorageDirectory() and not hard coded strings.
Some systems use /sdcard and some /mnt/sdcard or even /mnt/sdcard2.. Since you didn't post any code I cannot be sure if this solves the issue.
http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory%28%29

Android and PC Communication over USB: What is a safe directory that I can use ADB push/pull on and access from an Android app?

I am writing an application that will allow an android phone and java application on the computer to communicate over the USB cable. Using Bluetooth or Wifi is not an option in this case.
I found it very difficult to find a nice solution to this problem, and the Host/Accessory libariries seemed designed to hook the phone up to docks/cameras/circuitboards rather than simply a PC. This is my solution, let me know if there are better alternatives:
I'm going to create a Java application to use ADB to push files onto the phone, the phone will then check those files for changes and act accordingly.
It seems to work well so far, except I am using the /sdcard/ folder to hold these files. I want this app to work on phones without SD cards too, so I want to know if there is some other safe folder that I can count on being able to access from the PC with ADB and the android app as well.
(I have looked at INTERNAL STORAGE libraries, but I don't know where they store their data and if I can push/pull with them from ADB.)
Thanks in advance for any help!
Read this https://groups.google.com/forum/?fromgroups#!topic/android-developers/tZrxqZQLh98
Nice discussion about holding tmp files.
Do u want to control your application from PC? Cant you use Intents launched by ADB for that?
Another options port forwarding over USB with ADB:
adb forward tcp:6100 tcp:7100
adb forward tcp:6100 local:logd
Personally I end-up doing GET requests to my local Apache server to fetch data.
Or on rooted device many folders become available.

Access SQLite DB without the emulator?

I have been trying to pull out my SQLite database from my android application onto my computer.
I only get results, when I run my application on the eclipse android emulator and then I can access to the DB. But the thing is using the emulator is to slow and it doesn't have all the data I have been storing on my app on the cellphone.
I have been googling that for a day and all I can see is "use the emulator".
Isn't it possible without the emulator ?
On commercially released Android devices, you aren't allowed access to your app's internal SQLite database (for security reasons). Thus, if you simply can't stand the emulator, or if you just want to test your app on an actual device to make sure it works properly, there are two options to consider.
Root your device. This will give you access to the /data folder where your app's internal SQLite database is stored.
Use a 3rd party library to write the contents of your database to the SD card. This is a nice workaround if you don't want to bother rooting your device. Check this post for one such implementation.
The SQLite database in your app is just a file. You can use the DDMS file view in Eclipse to pull the file off your device, but only if you have a rooted or development device, or if you're using the emulator.
Once youve got the file on your computer you'll be able to run queries against it using the sqlite3 command (which, depending on your system, you may have to install).

Categories