Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to load .3gp file link stored in sdcard to database
- public class DatabaseUtil {
- private static final String DB_NAME="call_recordings";
- private static final int DB_VERSION=1;
- SQLiteDatabase db;
- public DatabaseUtil(Context context) {
- MyHelper helper = new MyHelper(context);
- db = helper.getWritableDatabase();
- }
- public class MyHelper extends SQLiteOpenHelper
- {
- String root="/sdcard/AudioRecorder1";
- File directory = Environment.getExternalStorageDirectory();
- File f = new File(directory + root);
- File[] files = f.listFiles();
- String[] str1;
- String str2[];
- public void filepath(String s)
- {
- for(int i=0; i < files.length; i++)
- {
- File file = files[i];
- str1[i]=file.getPath();
- str2[i]=file.getName();
- System.out.println("file is"+str1[i]);
- addrecords(str2[i]);
- }
- }
- // File file[] = directory.listFiles();
- // System.out.println("The length of files is " + file.length);
- // for(int i=0;i<file.length;i++)
- //for each file object get any details you wish to using the standard functions...jst google :)
- public MyHelper(Context context) {
- super(context, DB_NAME, null, DB_VERSION);
- }
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL("create table recordings(path varchar)");
- }
- @Override
- public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
- }
- }
- public void addrecords(String sName)
- {
- SQLiteStatement stmt = db.compileStatement("insert into recordings values(?)");
- stmt.bindString(1, sName);
- //stmt.bindString(2, sQua);
- stmt.executeInsert();
- }
- public String getrecords()
- {``
- Cursor c = db.query("recordings", new String[]{"path"}, null, null, null, null, null);
- StringBuffer sb = new StringBuffer();
- if(c.moveToFirst())
- {
- do
- {
- sb.append(c.getString(0) + " : ");
- sb.append(c.getString(1) + "n");
- }while(c.moveToNext());
- }
- return sb.toString();
- }
- }
Add Comment
Please, Sign In to add comment