how to save a database on memory card as a file ?

by smc00...@gmail.com » Tue, 13 Jan 2009 01:09:11 GMT


Sponsored Links
 Can i save a database on memory card as a file ? and how to do it ?

Please give me a sample code,thanks

--~--~---------~--~----~------------~-------~--~----~



how to save a database on memory card as a file ?

by Sundog » Tue, 13 Jan 2009 03:41:47 GMT


 I did it the "trivial" way, write out sql statements to rebuild it
into a text file. If there's a more direct way I'd love to hear it.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. PROTECTION_SIGNATURE

Could someone help me with what this code means in relation to
defining my own permission?  The documentation doesn't have an
explanation but I think this might solve a problem i have if it is
what I think it is.

-- 

2. How to attach a video to an email...???

Hi everyone,

I am working on a Video App, where you can click on a video from the
sdcard. This click event opens a menu (I used a options menu) that
provides the user with different sharing options, e.g. email,
bluetooth etc. This part works fine so far... What I am now trying to
do is, when the user chooses "email" the app should open the email app
of the phone via an intent (this also works fine) and should directly
attach the video he clicked before to the new email .

The last part is, where I am stuck because I don't know how to tell
the app that the video that was clicked before to open the menu should
be attached to the mail:

Intent i = new Intent(Intent.ACTION_SEND);
                        i.setType("text/plain");
                        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        i.setType("video/mp4");
                        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new
File(Environment.getExternalStorageDirectory(),"DON'T KNOW HOW TO
ACCESS THE CLICKE FILENAME")));
                        startActivity(i);



I would appreciate any advice or help. Thank you in advance

...I will post my entire code below...


package com.mobilevideoeditor.moved;

import java.io.File;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;


public class ShareGalleryView extends Activity {
        private Cursor videocursor;
        private int video_column_index;
        int count;

        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.videogrid);

        //create new Grid View
        GridView vGrid=(GridView) findViewById(R.id.vgrid);
        registerForContextMenu(vGrid);
        vGrid.setAdapter(new VideoAdapter(this));

        init_phone_video_grid();

        vGrid.setOnItemClickListener(new OnItemClickListener() {

        @Override // click on item and open options menu
                public void onItemClick(AdapterView<?> parent, View v, int 
position,
long id) {
                        openOptionsMenu(); //Opens Options Menu by clicking on 
an item

                        }
        });

    }

        private void init_phone_video_grid() {
                System.gc();
                String[] proj = {
                                MediaStore.Video.Media._ID,
                                MediaStore.Video.Media.DISPLAY_NAME,
                                MediaStore.Video.Media.DATA
                };

                videocursor =
managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null,
null, null);
                count = videocursor.getCount();
                GridView vGrid=(GridView) findViewById(R.id.vgrid);
        vGrid.setAdapter(new VideoAdapter(this));
        }

        @Override //creates options menu with menu-items
        public boolean onCreateOptionsMenu(Menu menu) {

          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.menu_gallery_share, menu);
          return super.onCreateOptionsMenu(menu);
        }
        @Override //what happens when a menu item is clicked
        public boolean onOptionsItemSelected (MenuItem item){


                 try{
        //Facebook
        if (item.getItemId() == R.id.menu_facebook)
                {
                 //TODO open fb
                new AlertDialog.Builder(this)
                  .setTitle("No Service")
              .setMessage("Sorry, Facebook is not supported yet!")
              .setNeutralButton("Close", new
DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                                // TODO Auto-generated method stub
                    }}).show();
                        return true;

                }
           //YouTube
                else if (item.getItemId() == R.id.menu_youtube)
                {
                        //TODO open YouTube

                        new AlertDialog.Builder(this)
                          .setTitle("No Service")
                      .setMessage("Sorry, YouTube is not supported yet!")
                      .setNeutralButton("Close", new
DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int 
which) {
                                        // TODO Auto-generated method stub
                            }}).show();

                      return  true;
                }
                else if (item.getItemId() == R.id.menu_email)
                {

                        Intent i = new Intent(Intent.ACTION_SEND);
                        i.setType("text/plain");
                        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        i.setType("video/mp4");
                        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new
File(Environment.getExternalStorageDirectory(),"DON'T KNOW HOW TO
ACCESS THE CLICKE FILENAME")));
                        startActivity(i);

                        return true;

                }
                else if (item.getItemId() == R.id.menu_bluetooth)
                {
                        // TODO send via bluetooth
                        new AlertDialog.Builder(this)
                          .setTitle("No Service")
                      .setMessage("Sorry, Bluetooth is not supported yet!")
                      .setNeutralButton("Close", new
DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int 
which) {
                                        // TODO Auto-generated method stub
                            }}).show();
                        return true;

                }

                    }
                 catch(Exception e)
                    {
                    e.printStackTrace();
                    }
                      return super.onContextItemSelected(item);
        }


        public class VideoAdapter extends BaseAdapter {
        private Context vContext;

                public VideoAdapter(Context c) {
                    vContext = c;
            }

            public int getCount() {
                return count;
            }

            public Object getItem(int position) {
                return null;
            }

            public long getItemId(int position) {
                return 0;
            }

            // create a new ImageView for each item referenced by the Adapter
            public View getView(int position, View convertView, ViewGroup
parent) {
                System.gc();
                      TextView tv = new 
TextView(vContext.getApplicationContext());
                      String id = null;

                  if (convertView == null) {
                        video_column_index =
        
videocursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
                        videocursor.moveToPosition(position);
                        id = videocursor.getString(video_column_index);
                        tv.setText(id);
                  } else
                        tv = (TextView) convertView;
                  return tv;
                    }
            }

}



-- 

3. If and How to get video thumbnails?

4. OOT : WTA Paket sms termurah

5. Handroid1 (Porting Android to Samsung Vodafone 360 H1)

6. ftp blapk market apa ya

7. SIGSEGV on Droid X (libskia.so)