File Viewing code in XML (Samsung Galaxy Y) - java

I'm developing an android app to transfer files to a computer over a local area network.
I have finished the layout in XML, but one of my options is to open the files within the phone.
Does anyone know the code to view the files within my phone? or is there another way around it like using the default files application already installed on my phone?
I essentially need to be able to view the files so that the user can select which files need to be sent.
Does anyone know the solution to this?
Thanks a lot.

Related

How to share file between apps without file section interface

I am trying to make an app that can easily keep sending files to different apps(whichever the user is running currently), when those apps make request to my app for files.
I was going through this link Sharing a file in Android , Sharing simple data in android and also Sharecompat Blog.
In these links they use a chooser interface to select target apps which I don't want.
My goal is that those other apps can communicate with my app without any clicks or selection.
And In response I can provide them the necessary files.
But I couldn't find anything which can help me build my desired app.
How Can I do it?
Please, Any suggesstions.

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>.

Copy sqlite db file from Android terminal to Windows OS

I want to copy the sqlite database from data/data/[package name]/databases/ to Windows Operating system.
Currently, I am inside Android Terminal shell of Android studio and my current path is /data/data/example.com.sensor/databases.
There is a sqlite file in this directory. The name is sensor.sqlite.
This is perhaps an easy question for experience user like you.
However, I have spent 2 hours yet I find the result.
Thank you.
Regards,
Jimmy
Since your device is not rooted, you cannot do this from outside of the application. If it's your application, you can add a temporary routine into the application to copy the database to public storage, then use adb or MTP to copy the file to your Windows computer.
Or, you can just root your device.
See below attached image.
* To pull any file(note here you can pull only file,not folder).
-> As you can see just select your device from Device tab (On left).
-> Then Goto File Explorer tab and find path of your database.
As in image you can see I have open database directory of com.android.browser package application.
If you got some problem of finding your app package there, See another screen-shot below.And find app as directed there.
Steps :
Open Android Device Monitor.
Make sure your device is online & if your device is online, you will see like this in left side (Available device). Choose your device & in the centre at File Explorer tab, you can see the db file exists. The path is data/data/Your-Application-package/databases/Your-db-file
In the right top side, click Pull once you selected your db file and save it with extension .sqlite.

Android include audio files with app package

I need to build a standalone audio/music player that should be able to play different audio files in 2 languages, english and russian as they are selected.
I thought that would be and easy task since I found a lot of examples for a player that read from an SDCARD.
The problem is that in this specific case I want to bring the audio files within the app and read them from a specific folder inside the project (ex. /audio/eng/ or /audio/rus/). Is there a way to collect the audio files from one of these folders that come along with the app and play them?
I have very small experience in android applications but I wish to solve the problem.
Kind regards,
Chris

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.

Categories