Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I hava a SQLiteDatabase object called MyDb . this object can be filled by calling insertLocation method.

Java
public boolean insertLocation(String time, double latitude, double longitude) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues cV = new ContentValues();
        cV.put("time", time);
        cV.put("latitude", latitude);
        cV.put("longitude", longitude);
        db.insert("location", null, cV);
        return true;
    }


Now i want to put all these data to outputstream , how should i do this?
Posted
Updated 26-Oct-14 5:24am
v2

It depends exactly how you want to write it; use one of the derived classes listed at http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html[^].
 
Share this answer
 
You can write the data to OutputStream like this:
C#
DataOutputStream output = null;
        try {
            output = new DataOutputStream(
                    new BufferedOutputStream(
                            new FileOutputStream(new File("output.dat"))));
            output.writeUTF(time);
            output.writeLong(latitude);
            output.writeLong(longitude);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        finally {
            if (output != null)
                try {
                    output.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900