Accessing android app data from my computer.

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Feb 28, 2015 12:34:10 PM via Website

Hi, I'm developing a simple android sketching app as a part of a project. I want to know if it is possible to be able to save the app data in my computer. For more detail:

I am interested in the coordinates of the points where I touch the screen on my android device and want to use these for further work in my computer. Therefore, I need a way that I can access these from my computer. I have seen that I can print out the coordinates in Android Studio at runtime, with the device connected through USB. Is there any way that I can save these in my computer in the text file? I created a list and pushed all the coordinates into that, but am not sure where that is being saved and how to write that in a file in my own computer.

This is the relevant code. The commented part is what I tried doing but didn't work:

[...]
import java.io.*;
import java.io.BufferedWriter;
import java.util.ArrayList;

public class DrawingView extends View {
    private static final String TAG = "MyActivity";
    //    Writer writer;
    //    FileOutputStream file;
    ArrayList coords;

    //drawing path
    private Path drawPath;
    //drawing and canvas paint
    private Paint drawPaint, canvasPaint;
    //initial color
    private int paintColor = 0xFF660000;
    //canvas
    private Canvas drawCanvas;
    //canvas bitmap
    private Bitmap canvasBitmap;
    private float brushSize, lastBrushSize;
    private boolean erase=false;

    public DrawingView(Context context, AttributeSet attrs){
        super(context, attrs);
        setupDrawing();
        coords = new ArrayList();
    }

    private void setupDrawing(){
        //get drawing area setup for interaction
        drawPath = new Path();
        drawPaint = new Paint();
        drawPaint.setColor(paintColor);
        drawPaint.setAntiAlias(true);
        drawPaint.setStrokeWidth(20);
        drawPaint.setStyle(Paint.Style.STROKE);
        drawPaint.setStrokeJoin(Paint.Join.ROUND);
        drawPaint.setStrokeCap(Paint.Cap.SQUARE);
        canvasPaint = new Paint(Paint.DITHER_FLAG);
        brushSize = getResources().getInteger(R.integer.medium_size);
        lastBrushSize = brushSize;
        drawPaint.setStrokeWidth(brushSize);
    }

    [...]

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        //detect user touch
        float touchX = event.getX();
        float touchY = event.getY();

        String x = Float.toString(touchX);
        String y = Float.toString(touchY);
        String c = "(" + x + ", " + y + ")";
        Log.d(TAG, c);
        coords.add(c);

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                drawPath.moveTo(touchX, touchY);
                break;
            case MotionEvent.ACTION_MOVE:
                drawPath.lineTo(touchX, touchY);
                break;
            case MotionEvent.ACTION_UP:
                drawCanvas.drawPath(drawPath, drawPaint);
                drawPath.reset();
                break;
            default:
                return false;
        }
        //try {
            //writer = new BufferedWriter(new OutputStreamWriter(file, "utf-8"));
            //writer.write("Something");
        //} catch(IOException e){
            ////report
        //}

        invalidate();
        return true;
    }

    [...]

}