mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-16 10:03:14 -07:00
Adding Data Store implementations for Android and normal Java
This commit is contained in:
parent
742c59a7c7
commit
a9307693a6
4 changed files with 155 additions and 0 deletions
40
java/src/com/zerotier/one/AndroidFileProvider.java
Normal file
40
java/src/com/zerotier/one/AndroidFileProvider.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package com.zerotier.one;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class AndroidFileProvider implements DataStoreFileProvider {
|
||||
Context _ctx;
|
||||
|
||||
AndroidFileProvider(Context ctx) {
|
||||
this._ctx = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInputStream getInputFileStream(String name)
|
||||
throws FileNotFoundException {
|
||||
// TODO Auto-generated method stub
|
||||
return _ctx.openFileInput(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileOutputStream getOutputFileStream(String name)
|
||||
throws FileNotFoundException {
|
||||
// TODO Auto-generated method stub
|
||||
return _ctx.openFileOutput(name, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(String name) throws IOException {
|
||||
boolean success = _ctx.deleteFile(name);
|
||||
if(!success)
|
||||
{
|
||||
throw new IOException("Unable to delete file.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue