This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createTable(String tableName, Map<String, String> fields, SQLiteDatabase db) { | |
Iterator iter = fields.entrySet().iterator(); | |
String columns = "("; | |
Log.d("column", columns); | |
int counter = 1; | |
while (iter.hasNext()) { | |
Map.Entry mEntry = (Map.Entry) iter.next(); | |
columns += mEntry.getKey() + " " + mEntry.getValue(); | |
if (counter == fields.size()) { | |
columns += ")"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseHelper extends SQLiteOpenHelper { | |
private static final String DATABASE_NAME = "data.db"; | |
private static final int DATABASE_VERSION = 1; | |
public DatabaseHelper(Context context) { | |
super(context, DATABASE_NAME, null, DATABASE_VERSION); | |
} | |
@Override | |
public void onCreate(SQLiteDatabase db) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseInfo { | |
// Database Tables | |
public static String DATABASE_TABLE_A = "table_A"; | |
public static String DATABASE_TABLE_A_DETAILS = "table_a_details"; | |
public static String DATABASE_TABLE_B = "table_B"; | |
public static String DATABASE_TABLE_B_DETAILS = "table_b_details"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum EnumFields { | |
PRIMARY("INTEGER PRIMARY KEY"), | |
INTEGER("INTEGER"), | |
TEXT("TEXT"); | |
// Add more types | |
private String fields; | |
Fields(String fields){ | |
this.fields = fields; | |
} | |
public String getField(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
private String name; | |
private String address; | |
private String email; | |
private String phoneNumber; | |
private String passportNumber; | |
private int age; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IStoreRepository { | |
fun saveStudentData(student: Student) : Boolean | |
fun updateStudentData(student: Student) : Int | |
fun deleteStudentData (student: Student) : Boolean | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatabaseRepository : IStoreRepository { | |
private var realm: Realm = Realm.getDefaultInstance() | |
override fun saveStudentData(student: Student): Boolean { | |
try { | |
realm.executeTransaction { | |
realm.insertOrUpdate(student) | |
} | |
} catch (e: Exception) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getFile(View view) { | |
Intent intent = new Intent(); | |
intent.setType("video/*"); | |
intent.setAction(Intent.ACTION_GET_CONTENT); | |
startActivityForResult(Intent.createChooser(intent, "Select Video"), REQUEST_CODE_PICKER); | |
} | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void uploadFile(File file){ | |
RequestBody videoBody = RequestBody.create(MediaType.parse("video/"), file); | |
MultipartBody.Part vFile = MultipartBody.Part.createFormData("upload-file", file.getName(), videoBody); | |
UploadVideoService videoService = RetrofitClientInstance.Companion.getRetrofitInstance(); | |
Call<ResponseBody> serverCom=videoService.uploadVideo(vFile); | |
serverCom.enqueue(new Callback<ResponseBody>() { | |
@Override | |
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | |
ResponseBody body = response.body(); | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getRealVideoPathFromURI(contentResolver: ContentResolver, | |
contentURI: Uri): String? { | |
val cursor=contentResolver.query(contentURI, null, null, null, null) | |
if (cursor == null) | |
return contentURI.path | |
else { | |
cursor.moveToFirst() | |
val idx=cursor.getColumnIndex(MediaStore.Video.VideoColumns.DATA) | |
try { | |
return cursor.getString(idx) |
OlderNewer